Skip to content

Commit

Permalink
minor XSLT updates
Browse files Browse the repository at this point in the history
  • Loading branch information
agracio committed Dec 30, 2024
1 parent 9c73011 commit 607ca18
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 36 deletions.
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@ https://github.com/adamgruber/mochawesome
### JUnit

- Converts **<properties>**, **<system-out>** and **<system-err>** elements to Mochawesome test context.
- Nested test suites currently not supported.
- Nested test suites only supported when using `transformJunit: true` option. This will flatten nested test suites.

### NUnit

- NUnit XML version 3 and higher is supported.
- Converts **<properties>** elements to JUnit **<properties>**.
- Converts **<output>** elements to JUnit **<system-out>**.
- Nested `test-suite` elements are flattened.

### xUnit.net

Expand All @@ -88,7 +87,7 @@ https://github.com/adamgruber/mochawesome
### Usage

```bash
npm i mochawesome-converter
npm i --save-dev mochawesome-converter
```

```js
Expand All @@ -100,30 +99,32 @@ let options = {
junit: true
}

convert(options).then(() => console.log(`Report created: ${options.reportDir}/${options.reportFilename}`));
convert(options).then(() => console.log(`Mochawesome report created`));
```

### Options

| Option | Type | Default | Description |
|:--------------------------|:--------|:--------------------------|:---------------------------------------------|
| `testFile` **(required)** | string | | Path to test file for conversion |
| `testType` **(required)** | string | | Test report type |
| `reportDir` | string | ./report | Converted report output path |
| `reportFilename` | string | mochawesome.json | Mochawesome report name |
| `junit` | boolean | false | Create JUnit report? |
| `junitReportFilename` | string | `testFile.name`-junit.xml | JUnit report file name |
| `html` | boolean | false | Create Mochawesome HTML? |
| `htmlReportFilename` | string | mochawesome.html | Mochawesome HTML file name |
| `skippedAsPending` | boolean | true | Show skipped tests as pending in Mochawesome |
| `switchClassnameAndName` | boolean | false | Switch test case classname and name |
| Option | Type | Default | Description |
|:--------------------------|:--------|:--------------------------|:--------------------------------------------------|
| `testFile` **(required)** | string | | Path to test file for conversion |
| `testType` **(required)** | string | | Test report type |
| `reportDir` | string | ./report | Converted report output path |
| `reportFilename` | string | mochawesome.json | Mochawesome report name |
| `junit` | boolean | false | Create JUnit report? |
| `junitReportFilename` | string | `testFile.name`-junit.xml | JUnit report file name |
| `transformJunit` | boolean | false | Transform JUnit test file with nested test suites |
| `html` | boolean | false | Create Mochawesome HTML? |
| `htmlReportFilename` | string | mochawesome.html | Mochawesome HTML file name |
| `skippedAsPending` | boolean | true | Show skipped tests as pending in Mochawesome |
| `switchClassnameAndName` | boolean | false | Switch test case classname and name |

- `testFile` - relative or absolute path to input test file.
- `testType` - type of test report, not case-sensitive.
- `reportDir` - will be created if path does not exist.
- `skippedAsPending` - Mocha always reports skipped tests as pending and this is default behaviour of converter.
Set to `false` to display tests as skipped.
- `switchClassnameAndName` - Switches classname and name attributes of testcase in case your test naming data is generated in reverse order.
- `switchClassnameAndName` - Switches classname and name attributes of testcase if your test naming data is generated in reverse order.
- `transformJunit` - Uses XSLT processor to flatten any nested JUnit test suites. Setting `junit: true` will produce processed JUnit file.

#### Supported `testType` options.

Expand Down
1 change: 1 addition & 0 deletions src/nunit-junit.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
</xsl:if>
<xsl:apply-templates select="properties"/>
<xsl:apply-templates select="output"/>
<xsl:apply-templates select="test-case"/>
</testcase>
</xsl:template>

Expand Down
22 changes: 3 additions & 19 deletions src/xunit-junit.xslt
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:csl="http://www.w3.org/1999/XSL/Transform">
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>

<!-- <xsl:template match="/assemblies">-->
<!-- <xsl:variable name="tests" select="sum(assembly/@total)"/>-->
<!-- <xsl:variable name="time" select="format-number(sum(assembly/@time), '0.0000')"/>-->
<!-- <xsl:variable name="errors" select="sum(assembly/@errors)"/>-->
<!-- <xsl:variable name="failed" select="sum(assembly/@failed)"/>-->
<!-- <xsl:variable name="skipped" select="sum(assembly/@skipped)"/>-->
<!-- <testsuites tests="{$tests}" time="{$time}" errors="{$errors}" failures="{$failed}" skipped="{$skipped}">-->
<!-- <xsl:for-each select="assembly">-->
<!-- <xsl:sort select="name"/>-->
<!-- <xsl:variable name="assemblyFileName">-->
<!-- <xsl:call-template name="substring-after-last">-->
<!-- <xsl:with-param name="string" select="@name" />-->
<!-- <xsl:with-param name="delimiter" select="'\'" />-->
<!-- </xsl:call-template>-->
<!-- </xsl:variable>-->
<!-- <xsl:apply-templates select="collection"/>-->
<!-- </xsl:for-each>-->
<!-- </testsuites>-->
<!-- <xsl:apply-templates/>-->
<!-- </xsl:template>-->

<!-- <xsl:template match="assembly">-->
<xsl:template match="assemblies/assembly">
<xsl:variable name="timeStamp">
<xsl:value-of select="concat(@run-date, 'T', translate(@run-time, ',', '.'))" />
Expand Down

0 comments on commit 607ca18

Please sign in to comment.