# JenkinsPipelineUnit - how to test the addition of a test report

**URL:** <https://community.jenkins.io/t/jenkinspipelineunit-how-to-test-the-addition-of-a-test-report/36455>\
**Category:** Ask a question\
**Tags:** pipeline\
**Created:** [March 13, 2026, 4:27pm UTC](https://community.jenkins.io/t/jenkinspipelineunit-how-to-test-the-addition-of-a-test-report/36455 "2026-03-13T16:27:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mo0rBy](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/mo0rby/32/9702_2.png) [@Mo0rBy](https://community.jenkins.io/u/Mo0rBy)\
**Post date:** [March 13, 2026, 4:27pm UTC](https://community.jenkins.io/t/jenkinspipelineunit-how-to-test-the-addition-of-a-test-report/36455/1 "2026-03-13T16:27:50Z")

</div>

I am using JenkinsPipelineUnit to add some simple unit testing to my Jenkins shared-library. I may add some proper integration testing at a later date which I could solve this problem with, but I’d prefer to do it by unit test if possible.  
I love the library btw, it works really nicely.

So, I my problem is that I would like to test some conditional logic that:

1. I run unit tests
2. If test fail, I use `catchError()` to catch the error and continue pipeline execution (while marking the stage & pipeline UNSTABLE) because I want to…
3. Publish/attach the test report to Jenkins - using `publishHTML`, `junit`, whatever, it doesn’t really matter too much.
4. The settings for capturing the test report should be such `allowEmpty = false` so if there was a larger error during unit test execution, like a compile error, instead of a simple assertion error, the test report file is not created, and the stage & pipeline will result in a proper error and exit immediately.

I have this logic setup correctly for real pipeline execution and I would now like to add a unit test for it.

I have added this to my `BasePipelineTest` class to mock the output of `publishHTML` and I just got this from a real pipeline execution log and modified it so that it will change with input options:

```groovy
				        helper.registerAllowedMethod('publishHTML', [Map], { Map args ->
							println('[htmlpublisher] Archiving HTML reports...')
							println("[htmlpublisher] Archiving at BUILD level /home/jenkins/agent/workspace/test/test-job/${args.reportDir} to ${URLEncoder.encode(args.reportName, 'UTF-8')}")
							println('[htmlpublisher] Copying recursive using current thread')
						})

```

Now I can see this output right at the top of my callstack output for some reason, instead of where the `publishHTML` method is called, which is a bit odd, and I was wondering if I could somehow mock the previous test command (`./gradlew test` or `mvn verify` or whatever test command is ran before) to create (or not create) a file, and then I can test this `publishHTML` bit properly.

Or…is this all too close to an integration test and I should just do that?
