Skip to content

Commit 1aead4d

Browse files
mw-kapilgtaguptamw
andauthored
Add Code Coverage, Model Coverage and Test results report for HTML (#149)
* build * remove comment * html code coverage * html model coverage and html test report * update task.json * test code coverage html in template.yml * test commit * add folder for code cov html * fix cod cov html * fix code coverage html * update code coverage html * comment added * remove comment * test results html * skip version 0 * fix test results html * remove TestRunner.withTextOutput * model coverage HTML * add condition in model coverage HTML * upload artifacts * verify html file creation and remove upload artifact * remove file verification in model coverage and upload artifacts * fix upload results * fix artifacts * artifacts * model coverage html verification * final fix model coverage * remove model coverage file verification * ls the files * add model cov verif * remove ls * refactoring * change report to results * fix namings * remove tab space * Fix path namings * add File path * Add table entries for HTML test and coverage artifacts * Remove extra trademark symbol --------- Co-authored-by: tagupta <[email protected]>
1 parent 7f767df commit 1aead4d

File tree

7 files changed

+91
-19
lines changed

7 files changed

+91
-19
lines changed

build-test-publish.pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 1.13$(Rev:.r)
1+
name: 1.14$(Rev:.r)
22

33
trigger:
44
- master

integ-test-promote-template.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ jobs:
209209
displayName: Run MATLAB tests producing artifacts
210210
inputs:
211211
testResultsJUnit: test-results/matlab/results.xml
212+
testResultsHTML: test-results/matlab/resultsHTML
212213
codeCoverageCobertura: code-coverage/coverage.xml
214+
codeCoverageHTML: code-coverage/coverageHTML
213215
sourceFolder: src
214216
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABTests.RunMATLABTests@${{ version }}
215217
displayName: Run MATLAB tests filter by folder
@@ -225,10 +227,22 @@ jobs:
225227
set -e
226228
grep -q FirstTest test-results/matlab/results.xml
227229
displayName: Verify test results file was created
230+
- bash: |
231+
set -e
232+
test -d test-results/matlab/resultsHTML
233+
test -f test-results/matlab/resultsHTML/*.html
234+
displayName: Verify HTML test results folder and HTML file was created
235+
condition: not(eq(${{ version }}, '0'))
228236
- bash: |
229237
set -e
230238
grep -q add code-coverage/coverage.xml
231239
displayName: Verify code coverage file was created
240+
- bash: |
241+
set -e
242+
test -d code-coverage/coverageHTML
243+
test -f code-coverage/coverageHTML/*.html
244+
displayName: Verify HTML code coverage folder and HTML file was created
245+
condition: not(eq(${{ version }}, '0'))
232246
- bash: |
233247
set -e
234248
grep -q simpleTest test-results/matlab/selectbyfolder.xml
@@ -273,7 +287,7 @@ jobs:
273287
sourceFolder: src
274288
- bash: |
275289
set -e
276-
grep -q "TestRunner.withTextOutput('OutputDetail', 3)" console.log
290+
grep -q "('OutputDetail', 3)" console.log
277291
rm console.log
278292
displayName: Verify tests ran with detailed display level for event details
279293
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABTests.RunMATLABTests@${{ version }}
@@ -283,7 +297,7 @@ jobs:
283297
sourceFolder: src
284298
- bash: |
285299
set -e
286-
grep -q "TestRunner.withTextOutput('LoggingLevel', 3)" console.log
300+
grep -q "('LoggingLevel', 3)" console.log
287301
rm console.log
288302
displayName: Verify tests ran with detailed verbosity level for logged diagnostics
289303
- bash: |
@@ -346,6 +360,7 @@ jobs:
346360
inputs:
347361
selectByFolder: "simtests"
348362
modelCoverageCobertura: test-results/matlab/modelcoverage.xml
363+
modelCoverageHTML: test-results/matlab/modelcoverageHTML
349364
testResultsSimulinkTest: test-results/matlab/stmResult.mldatx
350365
testResultsPDF: test-results/matlab/results.pdf
351366
condition: eq(variables['Agent.OS'], 'Linux')
@@ -354,6 +369,12 @@ jobs:
354369
grep -q new_temp_model test-results/matlab/modelcoverage.xml
355370
displayName: Verify Model coverage was created
356371
condition: eq(variables['Agent.OS'], 'Linux')
372+
- bash: |
373+
set -e
374+
test -d test-results/matlab/modelcoverageHTML
375+
test -f test-results/matlab/modelcoverageHTML/*.html
376+
displayName: Verify HTML Model coverage folder and HTML file was created
377+
condition: not(eq(${{ version }}, '0'))
357378
- bash: |
358379
set -e
359380
test -f test-results/matlab/stmResult.mldatx

overview.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,14 @@ Input | Description
233233
`useParallel` | <p>(Optional) Option to run tests in parallel, specified as `false` or `true`. By default, the value is `false` and tests run in serial. If the test runner configuration is suited for parallelization, you can specify a value of `true` to run tests in parallel. This input requires a Parallel Computing Toolbox license.</p><p>**Example:** `useParallel: true`</p>
234234
`outputDetail` | <p>(Optional) Amount of event detail displayed for the test run, specified as `none`, `terse`, `concise`, `detailed`, or `verbose`. By default, the task displays failing and logged events at the `detailed` level and test run progress at the `concise` level.<p></p>**Example:** `outputDetail: verbose`</p>
235235
`loggingLevel` | <p>(Optional) Maximum verbosity level for logged diagnostics included for the test run, specified as `none`, `terse`, `concise`, `detailed`, or `verbose`. By default, the task includes diagnostics logged at the `terse` level.<p></p>**Example:** `loggingLevel: detailed`</p>
236-
`testResultsPDF` | <p>(Optional) Location to write the test results in PDF format, specified as a path relative to the project root folder. On macOS platforms, this input is supported in MATLAB R2020b and later.</p><p>**Example:** `testResultsPDF: test-results/results.pdf`</p>
237-
`testResultsJUnit` | <p>(Optional) Location to write the test results in JUnit-style XML format, specified as a path relative to the project root folder.</p><p>**Example:** `testResultsJUnit: test-results/results.xml`</p>
238-
`testResultsSimulinkTest` | <p>(Optional) Location to export Simulink Test Manager results in MLDATX format, specified as a path relative to the project root folder. This input requires a Simulink Test license and is supported in MATLAB R2019a and later.</p><p>**Example:** `testResultsSimulinkTest: test-results/results.mldatx`</p>
239-
`codeCoverageCobertura` | <p>(Optional) Location to write the code coverage results in Cobertura XML format, specified as a path relative to the project root folder.</p><p>**Example:** `codeCoverageCobertura: code-coverage/coverage.xml`</p>
240-
`modelCoverageCobertura` | <p>(Optional) Location to write the model coverage results in Cobertura XML format, specified as a path relative to the project root folder. This input requires a Simulink Coverage&trade; license and is supported in MATLAB R2018b and later.</p><p>**Example:** `modelCoverageCobertura: model-coverage/coverage.xml`</p>
236+
`testResultsHTML` | <p>(Optional) Location to write the test results in HTML format, specified as a folder path relative to the project root folder.</p><p>**Example:** `testResultsHTML: test-results`</p>
237+
`testResultsPDF` | <p>(Optional) Location to write the test results in PDF format, specified as a file path relative to the project root folder. On macOS platforms, this input is supported in MATLAB R2020b and later.</p><p>**Example:** `testResultsPDF: test-results/results.pdf`</p>
238+
`testResultsJUnit` | <p>(Optional) Location to write the test results in JUnit-style XML format, specified as a file path relative to the project root folder.</p><p>**Example:** `testResultsJUnit: test-results/results.xml`</p>
239+
`testResultsSimulinkTest` | <p>(Optional) Location to export Simulink Test Manager results in MLDATX format, specified as a file path relative to the project root folder. This input requires a Simulink Test license and is supported in MATLAB R2019a and later.</p><p>**Example:** `testResultsSimulinkTest: test-results/results.mldatx`</p>
240+
`codeCoverageHTML` | <p>(Optional) Location to write the code coverage results in HTML format, specified as a folder path relative to the project root folder.</p><p>**Example:** `codeCoverageHTML: code-coverage`</p>
241+
`codeCoverageCobertura` | <p>(Optional) Location to write the code coverage results in Cobertura XML format, specified as a file path relative to the project root folder.</p><p>**Example:** `codeCoverageCobertura: code-coverage/coverage.xml`</p>
242+
`modelCoverageHTML` | <p>(Optional) Location to write the model coverage results in HTML format, specified as a folder path relative to the project root folder. This input requires a Simulink Coverage&trade; license and is supported in MATLAB R2018b and later.</p><p>**Example:** `modelCoverageHTML: model-coverage`</p>
243+
`modelCoverageCobertura` | <p>(Optional) Location to write the model coverage results in Cobertura XML format, specified as a file path relative to the project root folder. This input requires a Simulink Coverage license and is supported in MATLAB R2018b and later.</p><p>**Example:** `modelCoverageCobertura: model-coverage/coverage.xml`</p>
241244
`startupOptions` | <p>(Optional) MATLAB startup options, specified as a list of options separated by spaces. For more information about startup options, see [Commonly Used Startup Options](https://www.mathworks.com/help/matlab/matlab_env/commonly-used-startup-options.html).</p><p>Using this input to specify the `-batch` or `-r` option is not supported.</p><p>**Example:** `startupOptions: -nojvm`<br/>**Example:** `startupOptions: -nojvm -logfile output.log`</p>
242245

243246
>**Note:** To customize the pretest state of the system, you can specify startup code that automatically executes before your tests run. For information on how to specify startup or shutdown files in a MATLAB project, see [Automate Startup and Shutdown Tasks](https://www.mathworks.com/help/matlab/matlab_prog/automate-startup-and-shutdown-tasks.html). If your pipeline does not use a MATLAB project, specify the commands you want executed at startup in a `startup.m` file instead, and save the file to the root of your repository. See [`startup`](https://www.mathworks.com/help/matlab/ref/startup.html) for more information.

tasks/run-matlab-tests/v1/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ async function run() {
1111
const options: scriptgen.IRunTestsOptions = {
1212
JUnitTestResults: taskLib.getInput("testResultsJUnit"),
1313
CoberturaCodeCoverage: taskLib.getInput("codeCoverageCobertura"),
14+
HTMLCodeCoverage: taskLib.getInput("codeCoverageHTML"),
1415
SourceFolder: taskLib.getInput("sourceFolder"),
1516
SelectByFolder: taskLib.getInput("selectByFolder"),
1617
SelectByTag: taskLib.getInput("selectByTag"),
1718
CoberturaModelCoverage: taskLib.getInput("modelCoverageCobertura"),
19+
HTMLModelCoverage: taskLib.getInput("modelCoverageHTML"),
1820
SimulinkTestResults: taskLib.getInput("testResultsSimulinkTest"),
1921
PDFTestReport: taskLib.getInput("testResultsPDF"),
22+
HTMLTestReport: taskLib.getInput("testResultsHTML"),
2023
Strict: taskLib.getBoolInput("strict"),
2124
UseParallel: taskLib.getBoolInput("useParallel"),
2225
OutputDetail: taskLib.getInput("outputDetail"),

tasks/run-matlab-tests/v1/scriptgen.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ import * as path from "path";
55
export interface IRunTestsOptions {
66
JUnitTestResults?: string;
77
CoberturaCodeCoverage?: string;
8+
HTMLCodeCoverage?: string;
89
SourceFolder?: string;
910
PDFTestReport?: string;
11+
HTMLTestReport?: string;
1012
SimulinkTestResults?: string;
1113
CoberturaModelCoverage?: string;
14+
HTMLModelCoverage?: string;
1215
SelectByTag?: string;
1316
SelectByFolder?: string;
1417
Strict?: boolean;
@@ -22,10 +25,13 @@ export function generateCommand(options: IRunTestsOptions): string {
2225
`testScript = genscript('Test',` +
2326
`'JUnitTestResults','${options.JUnitTestResults || ""}',` +
2427
`'CoberturaCodeCoverage','${options.CoberturaCodeCoverage || ""}',` +
28+
`'HTMLCodeCoverage','${options.HTMLCodeCoverage || ""}',` +
2529
`'SourceFolder','${options.SourceFolder || ""}',` +
2630
`'PDFTestReport','${options.PDFTestReport || ""}',` +
31+
`'HTMLTestReport','${options.HTMLTestReport || ""}',` +
2732
`'SimulinkTestResults','${options.SimulinkTestResults || ""}',` +
2833
`'CoberturaModelCoverage','${options.CoberturaModelCoverage || ""}',` +
34+
`'HTMLModelCoverage','${options.HTMLModelCoverage || ""}',` +
2935
`'SelectByTag','${options.SelectByTag || ""}',` +
3036
`'SelectByFolder','${options.SelectByFolder || ""}',` +
3137
`'Strict',${options.Strict || false},` +

tasks/run-matlab-tests/v1/task.json

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,16 @@
100100
"defaultValue": "",
101101
"groupName": "testArtifacts",
102102
"required": false,
103-
"helpMarkDown": "Path to write the test results in PDF format (requires MATLAB R2020b or later on macOS platforms)."
103+
"helpMarkDown": "File path to write the test results in PDF format (requires MATLAB R2020b or later on macOS platforms)."
104+
},
105+
{
106+
"name": "testResultsHTML",
107+
"type": "string",
108+
"label": "HTML test report",
109+
"defaultValue": "",
110+
"groupName": "testArtifacts",
111+
"required": false,
112+
"helpMarkDown": "Folder path to write the test results in HTML format."
104113
},
105114
{
106115
"name": "testResultsJUnit",
@@ -109,7 +118,7 @@
109118
"defaultValue": "",
110119
"groupName": "testArtifacts",
111120
"required": false,
112-
"helpMarkDown": "Path to write the test results in JUnit-style XML format."
121+
"helpMarkDown": "File path to write the test results in JUnit-style XML format."
113122
},
114123
{
115124
"name": "testResultsSimulinkTest",
@@ -118,7 +127,7 @@
118127
"defaultValue": "",
119128
"groupName": "testArtifacts",
120129
"required": false,
121-
"helpMarkDown": "Path to export Simulink Test Manager results in MLDATX format (requires Simulink Test and is supported in MATLAB R2019a or later)."
130+
"helpMarkDown": "File path to export Simulink Test Manager results in MLDATX format (requires Simulink Test and is supported in MATLAB R2019a or later)."
122131
},
123132
{
124133
"name": "codeCoverageCobertura",
@@ -127,7 +136,16 @@
127136
"defaultValue": "",
128137
"required": false,
129138
"groupName": "coverageArtifacts",
130-
"helpMarkDown": "Path to write the code coverage results in Cobertura XML format."
139+
"helpMarkDown": "File path to write the code coverage results in Cobertura XML format."
140+
},
141+
{
142+
"name": "codeCoverageHTML",
143+
"type": "string",
144+
"label": "HTML code coverage",
145+
"defaultValue": "",
146+
"required": false,
147+
"groupName": "coverageArtifacts",
148+
"helpMarkDown": "Folder path to write the code coverage results in HTML format."
131149
},
132150
{
133151
"name": "modelCoverageCobertura",
@@ -136,7 +154,16 @@
136154
"defaultValue": "",
137155
"groupName": "coverageArtifacts",
138156
"required": false,
139-
"helpMarkDown": "Path to write the model coverage report in Cobertura XML format (requires Simulink Coverage and is supported in MATLAB R2018b or later)."
157+
"helpMarkDown": "File path to write the model coverage report in Cobertura XML format (requires Simulink Coverage and is supported in MATLAB R2018b or later)."
158+
},
159+
{
160+
"name": "modelCoverageHTML",
161+
"type": "string",
162+
"label": "HTML model coverage",
163+
"defaultValue": "",
164+
"groupName": "coverageArtifacts",
165+
"required": false,
166+
"helpMarkDown": "Folder path to write the model coverage results in HTML format (requires Simulink Coverage and is supported in MATLAB R2018b or later)."
140167
},
141168
{
142169
"name": "startupOptions",

0 commit comments

Comments
 (0)