Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 699d4a7

Browse files
authored
Merge pull request #360 from mathworks/kapilg/test-results-visualization
Add test results visualization
2 parents b98f08a + 6ccc534 commit 699d4a7

File tree

24 files changed

+2048
-144
lines changed

24 files changed

+2048
-144
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ src/main/resources/**/run-matlab-command*
88
src/main/resources/license.txt
99

1010
.idea/
11+
matlab.iml
1112

1213
**/.DS_Store

pom.xml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
<email>continuous-integration@mathworks.com</email>
2424
</developer>
2525
</developers>
26-
2726
<licenses>
2827
<license>
2928
<name>MIT License</name>
@@ -52,11 +51,13 @@
5251
<tag>HEAD</tag>
5352
</scm>
5453

55-
<properties>
56-
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
57-
<jenkins.baseline>2.387</jenkins.baseline>
58-
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
59-
</properties>
54+
<properties>
55+
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
56+
<jenkins.baseline>2.387</jenkins.baseline>
57+
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
58+
<maven.compiler.source>11</maven.compiler.source>
59+
<maven.compiler.target>11</maven.compiler.target>
60+
</properties>
6061

6162
<dependencyManagement>
6263
<dependencies>
@@ -71,6 +72,7 @@
7172
</dependencyManagement>
7273

7374
<dependencies>
75+
7476
<!-- JSON Parser -->
7577
<dependency>
7678
<groupId>com.googlecode.json-simple</groupId>

src/main/java/com/mathworks/ci/MatlabBuilderConstants.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.mathworks.ci;
22

33
/*
4-
* Copyright 2019-2024 The MathWorks, Inc.
4+
* Copyright 2019-2025 The MathWorks, Inc.
55
*/
66

77
public class MatlabBuilderConstants {
@@ -35,10 +35,14 @@ public class MatlabBuilderConstants {
3535
// Temporary MATLAB folder name in workspace
3636
public static final String TEMP_MATLAB_FOLDER_NAME = ".matlab";
3737

38-
// MATLAB default function/plugin paths
38+
// MATLAB default function, plugin, service paths
3939
public static final String DEFAULT_PLUGIN = "+ciplugins/+jenkins/getDefaultPlugins.m";
4040
public static final String BUILD_REPORT_PLUGIN = "+ciplugins/+jenkins/BuildReportPlugin.m";
4141
public static final String TASK_RUN_PROGRESS_PLUGIN = "+ciplugins/+jenkins/TaskRunProgressPlugin.m";
42+
public static final String TEST_RESULTS_VIEW_PLUGIN = "+ciplugins/+jenkins/TestResultsViewPlugin.m";
43+
public static final String TEST_RESULTS_VIEW_PLUGIN_SERVICE = "+matlab/+unittest/+internal/+services/+plugins/TestResultsViewPluginService.m";
44+
45+
public static final String TEST_RESULTS_VIEW_ARTIFACT = "matlabTestResults";
4246
public static final String BUILD_ARTIFACT = "buildArtifact";
4347

4448
public static final String NEW_LINE = System.getProperty("line.separator");
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.mathworks.ci;
2+
3+
/**
4+
* Copyright 2025, The MathWorks Inc.
5+
*
6+
* Class to store MATLAB test case information
7+
*
8+
*/
9+
10+
import java.util.List;
11+
import java.math.BigDecimal;
12+
import java.util.ArrayList;
13+
14+
import org.apache.commons.lang.RandomStringUtils;
15+
16+
import com.mathworks.ci.TestResultsViewAction.TestStatus;
17+
18+
public class MatlabTestCase {
19+
private String name;
20+
private List<MatlabTestDiagnostics> diagnostics;
21+
private TestStatus status;
22+
private BigDecimal duration;
23+
private String id;
24+
25+
public MatlabTestCase(String name) {
26+
this.name = name;
27+
this.diagnostics = new ArrayList<MatlabTestDiagnostics>();
28+
this.status = TestStatus.NOT_RUN;
29+
this.duration = new BigDecimal("0.0");
30+
this.id = RandomStringUtils.randomAlphanumeric(8);
31+
}
32+
33+
public String getName() {
34+
return this.name;
35+
}
36+
37+
public void setName(String name) {
38+
this.name = name;
39+
}
40+
41+
public List<MatlabTestDiagnostics> getDiagnostics() {
42+
return this.diagnostics;
43+
}
44+
45+
public void setDiagnostics(List<MatlabTestDiagnostics> diagnostics) {
46+
this.diagnostics = diagnostics;
47+
}
48+
49+
public TestStatus getStatus() {
50+
return this.status;
51+
}
52+
53+
public void setStatus(TestStatus status) {
54+
this.status = status;
55+
}
56+
57+
public BigDecimal getDuration() {
58+
return this.duration;
59+
}
60+
61+
public void setDuration(BigDecimal duration) {
62+
this.duration = duration;
63+
}
64+
65+
public String getId() {
66+
return this.id;
67+
}
68+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.mathworks.ci;
2+
3+
/**
4+
* Copyright 2025, The MathWorks Inc.
5+
*
6+
* Class to store MATLAB test diagnostics information
7+
*
8+
*/
9+
10+
import org.apache.commons.lang.RandomStringUtils;
11+
12+
public class MatlabTestDiagnostics {
13+
private String event;
14+
private String report;
15+
private String id;
16+
17+
public MatlabTestDiagnostics() {
18+
this.event = "";
19+
this.report = "";
20+
this.id = RandomStringUtils.randomAlphanumeric(8);
21+
}
22+
23+
public String getEvent() {
24+
return this.event;
25+
}
26+
27+
public void setEvent(String event) {
28+
this.event = event;
29+
}
30+
31+
public String getReport() {
32+
return this.report;
33+
}
34+
35+
public void setReport(String report) {
36+
this.report = report;
37+
}
38+
39+
public String getId() {
40+
return this.id;
41+
}
42+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package com.mathworks.ci;
2+
3+
/**
4+
* Copyright 2025, The MathWorks Inc.
5+
*
6+
* Class to store MATLAB test file information
7+
*
8+
*/
9+
10+
import java.util.List;
11+
import java.math.BigDecimal;
12+
import java.util.ArrayList;
13+
14+
import org.apache.commons.lang.RandomStringUtils;
15+
16+
import com.mathworks.ci.TestResultsViewAction.TestStatus;
17+
18+
public class MatlabTestFile {
19+
private String path;
20+
private String name;
21+
private BigDecimal duration;
22+
private TestStatus status;
23+
private List<MatlabTestCase> matlabTestCases;
24+
private String id;
25+
26+
public MatlabTestFile(String name) {
27+
this.name = name;
28+
this.path = "";
29+
this.duration = new BigDecimal("0.0");
30+
this.status = TestStatus.NOT_RUN;
31+
this.matlabTestCases = new ArrayList<MatlabTestCase>();
32+
this.id = RandomStringUtils.randomAlphanumeric(8);
33+
}
34+
35+
private void incrementDuration(BigDecimal matlabTestCaseDuration) {
36+
this.duration = this.duration.add(matlabTestCaseDuration);
37+
}
38+
39+
private void updateStatus(MatlabTestCase matlabTestCase) {
40+
if (!this.status.equals(TestStatus.FAILED)) {
41+
if (matlabTestCase.getStatus().equals(TestStatus.FAILED)){
42+
this.status = TestStatus.FAILED;
43+
}
44+
else if (!this.status.equals(TestStatus.INCOMPLETE)){
45+
if (matlabTestCase.getStatus().equals(TestStatus.INCOMPLETE)){
46+
this.status = TestStatus.INCOMPLETE;
47+
}
48+
else if (matlabTestCase.getStatus().equals(TestStatus.PASSED)){
49+
this.status = TestStatus.PASSED;
50+
}
51+
}
52+
}
53+
}
54+
55+
public void addTestCase(MatlabTestCase matlabTestCase){
56+
this.incrementDuration(matlabTestCase.getDuration());
57+
this.updateStatus(matlabTestCase);
58+
this.getMatlabTestCases().add(matlabTestCase);
59+
}
60+
61+
public String getPath() {
62+
return this.path;
63+
}
64+
65+
public void setPath(String path) {
66+
this.path = path;
67+
}
68+
69+
public String getName() {
70+
return this.name;
71+
}
72+
73+
public void setName(String name) {
74+
this.name = name;
75+
}
76+
77+
public BigDecimal getDuration() {
78+
return this.duration;
79+
}
80+
81+
public void setDuration(BigDecimal duration) {
82+
this.duration = duration;
83+
}
84+
85+
public TestStatus getStatus() {
86+
return this.status;
87+
}
88+
89+
public void setStatus(TestStatus status) {
90+
this.status = status;
91+
}
92+
93+
public List<MatlabTestCase> getMatlabTestCases() {
94+
return this.matlabTestCases;
95+
}
96+
97+
public void setMatlabTestCases(List<MatlabTestCase> matlabTestCases) {
98+
this.matlabTestCases = matlabTestCases;
99+
}
100+
101+
public String getId() {
102+
return this.id;
103+
}
104+
}

0 commit comments

Comments
 (0)