Skip to content

Commit

Permalink
Extend integration tests and sync README (#714)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioFuchsTT committed Aug 26, 2024
1 parent 3a891d3 commit 2b16189
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,10 @@ unclassified:
```
</details>
### Warnings NG Plugin
The [Warnings NG Plugin](https://plugins.jenkins.io/warnings-ng/) is used to record and manage issues within your Jenkins Pipelines. Supported versions of this plugin start at **11.0.0**. It is recommended to use these versions to ensure compatibility and stability.
## Debugging
To change the job console log level to debug, the system property `ecutest.debugLog` should be set to `true`. This could be done either at startup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,36 @@ public void recordError() throws Exception {
assertThat(build.getAction(ResultAction.class).getResult().getTotalErrorsSize(), is(1));
}

@Test
public void recordWarnings() throws Exception {
final String issueFileName = "warnings.json";
final String issues = loadTestResource(issueFileName);

final FreeStyleProject project = createProject(issueFileName, issues);
final FreeStyleBuild build = jenkins.buildAndAssertStatus(Result.SUCCESS, project);

jenkins.assertLogContains("found 1 file", build);
jenkins.assertLogContains("found 3 issues", build);
jenkins.assertLogContains("Successfully processed file '" + issueFileName + "'", build);

assertThat(build.getAction(ResultAction.class).getResult().getIssues().size(), is(3));
}

@Test
public void recordMixedSeverities() throws Exception {
final String issueFileName = "mixed-severities.json";
final String issues = loadTestResource(issueFileName);

final FreeStyleProject project = createProject(issueFileName, issues);
final FreeStyleBuild build = jenkins.buildAndAssertStatus(Result.FAILURE, project);

jenkins.assertLogContains("found 1 file", build);
jenkins.assertLogContains("found 3 issues", build);
jenkins.assertLogContains("Successfully processed file '" + issueFileName + "'", build);

assertThat(build.getAction(ResultAction.class).getResult().getIssues().size(), is(3));
}

private FreeStyleProject createProject(final String issueFileName, final String issues) throws IOException {
final FreeStyleProject project = jenkins.createFreeStyleProject();
project.getBuildersList().add(new TestBuilder() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"_class": "io.jenkins.plugins.analysis.core.restapi.ReportApi",
"issues": [
{
"description": "#1 Warning",
"fileName": "test.pkg",
"lineStart": 1,
"severity": "LOW"
},
{
"description": "#2 Info",
"fileName": "test.pkg",
"lineStart": 2,
"severity": "INFO"
},
{
"description": "#3 Error",
"fileName": "test.pkg",
"lineStart": 3,
"severity": "ERROR"
}
],
"size": 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"_class": "io.jenkins.plugins.analysis.core.restapi.ReportApi",
"issues": [
{
"description": "#1 Warning",
"fileName": "test.pkg",
"lineStart": 1,
"severity": "LOW"
},
{
"description": "#2 Warning",
"fileName": "test.pkg",
"lineStart": 2,
"severity": "NORMAL"
},
{
"description": "#3 Warning",
"fileName": "test.pkg",
"lineStart": 3,
"severity": "HIGH"
}
],
"size": 3
}

0 comments on commit 2b16189

Please sign in to comment.