Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add capturing checks publisher, make publishChecks withChecksName aware #55

Merged
merged 4 commits into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/consumers-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,10 @@ getContext().get(ChecksInfo.class)
Currently, the `ChecksInfo` object only includes a `name` specified by users,
it is recommended that you look for this name and set it over your default checks name

## Integration Testing

An implementation of `ChecksPublisher` that captures all published `ChecksDetails` is provided
in the `test` classifier, as `io.jenkins.plugins.checks.api.test.CapturingChecksPublisher`.

Adding the factory for this publisher as a `TestExtension` will allow inspection of published checks after running a job
on a `JenkinsRule`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add the link from the javadoc here as well,

to io.jenkins.plugins.checks.steps.PublishChecksStepITest

16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@
</analysisConfiguration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@XiongKezhi this is normally accomplished just with

<no-test-jar>false</no-test-jar>

For some reason you are inheriting from analysis-pom, which does things differently, rather than directly from org.jenkins-ci.plugins:plugin.

</goals>
<configuration>
<includes combine.children="append">
<include>**/api/test/**</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,29 @@
* For example:
*
* <pre>
* public class ChecksPublishingTest {
* public class ChecksPublishingTest extends IntegrationTestWithJenkinsPerTest {
*
* &#64;TestExtension
* public static final CapturingChecksPublisher.Factory PUBLISHER_FACTORY = new CapturingChecksPublisher.Factory();
*
* &#64;After
* public void clearPublishedChecks() {
* PUBLISHER_FACTORY.getPublishedChecks().clear();
* }
*
* &#64;Test
* public void testChecksPublishing() {
*
* // ...Run a test job...
*
* List&lt;ChecksDetails&gt; publishedDetails = PUBLISHER_FACTORY.getPublishedChecks();
*
* // ...Inspect published checks...
* }
* }
* </pre>
*
* An example of this can be found in {@link io.jenkins.plugins.checks.steps.PublishChecksStepITest}
*/
public class CapturingChecksPublisher extends ChecksPublisher {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.io.IOException;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.eq;

/**
* Tests the pipeline step to publish checks.
Expand Down
2 changes: 0 additions & 2 deletions src/test/resources/design.puml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ skinparam component {
}

[API] <<..checks.api>>
[Test] <<..checks.api.test>>
[Steps] <<..checks.steps>>
[Status] <<..checks.status>>
[Checks] <<..checks>>

[Steps] --> [API]
[Status] --> [API]
[Checks] --> [API]
[Test] --> [API]

@enduml