Compare commits

..

No commits in common. "master" and "0.9.0" have entirely different histories.

45 changed files with 405 additions and 1567 deletions

View file

@ -4,36 +4,29 @@ on: [ push, pull_request, workflow_dispatch ]
jobs: jobs:
build-bld-project: build-bld-project:
runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
java-version: [ 17, 21, 24 ] java-version: [ 17, 20 ]
kotlin-version: [ 1.9.25, 2.0.21, 2.1.20 ]
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout source repository - name: Checkout source repository
uses: actions/checkout@v4 uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }} - name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4 uses: actions/setup-java@v3
with: with:
distribution: "zulu" distribution: 'zulu'
java-version: ${{ matrix.java-version }} java-version: ${{ matrix.java-version }}
- name: Download dependencies [examples] - name: Grant execute permission for bld
working-directory: examples run: chmod +x bld
- name: Download the dependencies
run: ./bld download run: ./bld download
- name: Run tests with JaCoCo [examples] - name: Run tests with bld
working-directory: examples
run: ./bld compile jacoco
- name: Download dependencies
run: ./bld download
- name: Run tests
run: ./bld compile test run: ./bld compile test

View file

@ -30,14 +30,14 @@ jobs:
steps: steps:
- name: Checkout source repository - name: Checkout source repository
uses: actions/checkout@v4 uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Set up JDK 17 - name: Set up JDK 17
uses: actions/setup-java@v4 uses: actions/setup-java@v3
with: with:
distribution: "zulu" distribution: 'zulu'
java-version: 17 java-version: 17
- name: Build Javadocs - name: Build Javadocs
@ -47,11 +47,11 @@ jobs:
uses: actions/configure-pages@v3 uses: actions/configure-pages@v3
- name: Upload artifact - name: Upload artifact
uses: actions/upload-pages-artifact@v3 uses: actions/upload-pages-artifact@v1
with: with:
# Upload generated Javadocs repository # Upload generated Javadocs repository
path: "build/javadoc/" path: 'build/javadoc/'
- name: Deploy to GitHub Pages - name: Deploy to GitHub Pages
id: deployment id: deployment
uses: actions/deploy-pages@v4 uses: actions/deploy-pages@v1

1
.gitignore vendored
View file

@ -55,4 +55,3 @@ atlassian-ide-plugin.xml
.idea/httpRequests .idea/httpRequests
local.properties local.properties
test-output

6
.idea/bld.xml generated
View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BldConfiguration">
<events />
</component>
</project>

View file

@ -1,6 +1,6 @@
<component name="CopyrightManager"> <component name="CopyrightManager">
<copyright> <copyright>
<option name="notice" value="Copyright 2023-&amp;#36;today.year the original author or authors.&#10; &#10;Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&#10;you may not use this file except in compliance with the License.&#10;You may obtain a copy of the License at&#10;&#10; https://www.apache.org/licenses/LICENSE-2.0&#10;&#10;Unless required by applicable law or agreed to in writing, software&#10;distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&#10;WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&#10;See the License for the specific language governing permissions and&#10;limitations under the License." /> <option name="notice" value=" Copyright &amp;#36;today.year the original author or authors.&#10; &#10; Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&#10; you may not use this file except in compliance with the License.&#10; You may obtain a copy of the License at&#10; &#10; https://www.apache.org/licenses/LICENSE-2.0&#10; &#10; Unless required by applicable law or agreed to in writing, software&#10; distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&#10; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&#10; See the License for the specific language governing permissions and&#10; limitations under the License." />
<option name="myName" value="Apache License" /> <option name="myName" value="Apache License" />
</copyright> </copyright>
</component> </component>

13
.idea/icon.svg generated
View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 179 108" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g transform="matrix(1,0,0,1,-210.511,-96.3382)">
<g transform="matrix(1,0,0,1,-23.3386,-649.816)">
<g transform="matrix(0.221288,0,0,0.24,73.9536,390.254)">
<path d="M722.568,1482.92L722.568,1921.1L808.968,1921.1L808.968,1888.7C822.168,1907.9 846.168,1930.1 893.568,1930.1C933.168,1930.1 961.968,1917.5 985.368,1893.5C1012.97,1865.9 1027.37,1827.5 1027.37,1786.1C1027.37,1741.7 1011.17,1705.1 985.368,1680.5C961.968,1658.3 928.968,1644.5 892.368,1644.5C862.968,1644.5 830.568,1654.1 808.968,1683.5L808.968,1482.92L722.568,1482.92ZM871.368,1718.9C888.768,1718.9 903.768,1723.7 917.568,1736.9C930.168,1748.9 938.568,1766.3 938.568,1787.9C938.568,1807.7 930.168,1825.1 917.568,1837.1C904.368,1849.7 887.568,1855.7 872.568,1855.7C856.368,1855.7 837.168,1849.1 823.368,1835.9C813.168,1826.3 803.568,1810.1 803.568,1787.9C803.568,1765.1 812.568,1749.5 822.768,1738.7C836.568,1724.3 852.768,1718.9 871.368,1718.9Z" style="fill:rgb(35,146,255);fill-rule:nonzero;"/>
<rect x="1083.77" y="1482.92" width="86.4" height="438.182" style="fill:rgb(250,144,82);fill-rule:nonzero;"/>
<path d="M1531.37,1482.92L1444.97,1482.92L1444.97,1683.5C1423.37,1654.1 1390.97,1644.5 1361.57,1644.5C1324.97,1644.5 1291.97,1658.3 1268.57,1680.5C1242.77,1705.1 1226.57,1741.7 1226.57,1786.1C1226.57,1827.5 1240.97,1865.9 1268.57,1893.5C1291.97,1917.5 1320.77,1930.1 1360.37,1930.1C1407.77,1930.1 1431.77,1907.9 1444.97,1888.7L1444.97,1921.1L1531.37,1921.1L1531.37,1482.92ZM1382.57,1718.9C1401.17,1718.9 1417.37,1724.3 1431.17,1738.7C1441.37,1749.5 1450.37,1765.1 1450.37,1787.9C1450.37,1810.1 1440.77,1826.3 1430.57,1835.9C1416.77,1849.1 1397.57,1855.7 1381.37,1855.7C1366.37,1855.7 1349.57,1849.7 1336.37,1837.1C1323.77,1825.1 1315.37,1807.7 1315.37,1787.9C1315.37,1766.3 1323.77,1748.9 1336.37,1736.9C1350.17,1723.7 1365.17,1718.9 1382.57,1718.9Z" style="fill:rgb(35,146,255);fill-rule:nonzero;"/>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -1,204 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaDocConfiguration">
<GENERAL>
<MODE>UPDATE</MODE>
<OVERRIDDEN_METHODS>false</OVERRIDDEN_METHODS>
<SPLITTED_CLASS_NAME>true</SPLITTED_CLASS_NAME>
<LEVELS>
<LEVEL>TYPE</LEVEL>
<LEVEL>METHOD</LEVEL>
<LEVEL>FIELD</LEVEL>
</LEVELS>
<VISIBILITIES>
<VISIBILITY>PROTECTED</VISIBILITY>
<VISIBILITY>DEFAULT</VISIBILITY>
<VISIBILITY>PUBLIC</VISIBILITY>
</VISIBILITIES>
</GENERAL>
<TEMPLATES>
<CLASSES>
<CLASS>
<KEY>^.*(public|protected|private)*.+interface\s+\w+.*</KEY>
<VALUE>/**\n
* The interface ${name}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
*/</VALUE>
</CLASS>
<CLASS>
<KEY>^.*(public|protected|private)*.+enum\s+\w+.*</KEY>
<VALUE>/**\n
* The enum ${name}.\n
*/</VALUE>
</CLASS>
<CLASS>
<KEY>^.*(public|protected|private)*.+class\s+\w+.*</KEY>
<VALUE>/**\n
* The type ${name}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
*/</VALUE>
</CLASS>
<CLASS>
<KEY>.+</KEY>
<VALUE>/**\n
* The type ${name}.\n
*/</VALUE>
</CLASS>
</CLASSES>
<CONSTRUCTORS>
<CONSTRUCTOR>
<KEY>.+</KEY>
<VALUE>/**\n
* Instantiates a new ${name}.\n
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</CONSTRUCTOR>
</CONSTRUCTORS>
<METHODS>
<METHOD>
<KEY>^.*(public|protected|private)*\s*.*(\w(\s*&lt;.+&gt;)*)+\s+get\w+\s*\(.*\).+</KEY>
<VALUE>/**\n
* Gets ${partName}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if isNotVoid&gt;
*\n
* @return the ${partName}\n
&lt;/#if&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
<METHOD>
<KEY>^.*(public|protected|private)*\s*.*(void|\w(\s*&lt;.+&gt;)*)+\s+set\w+\s*\(.*\).+</KEY>
<VALUE>/**\n
* Sets ${partName}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if isNotVoid&gt;
*\n
* @return the ${partName}\n
&lt;/#if&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
<METHOD>
<KEY>^.*((public\s+static)|(static\s+public))\s+void\s+main\s*\(\s*String\s*(\[\s*\]|\.\.\.)\s+\w+\s*\).+</KEY>
<VALUE>/**\n
* The entry point of application.\n
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
* @param ${element.parameterList.parameters[0].name} the input arguments\n
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
<METHOD>
<KEY>.+</KEY>
<VALUE>/**\n
* ${name}&lt;#if isNotVoid&gt; ${return}&lt;/#if&gt;.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if isNotVoid&gt;
*\n
* @return the ${return}\n
&lt;/#if&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
</METHODS>
<FIELDS>
<FIELD>
<KEY>^.*(public|protected|private)*.+static.*(\w\s\w)+.+</KEY>
<VALUE>/**\n
* The constant ${element.getName()}.\n
*/</VALUE>
</FIELD>
<FIELD>
<KEY>^.*(public|protected|private)*.*(\w\s\w)+.+</KEY>
<VALUE>/**\n
&lt;#if element.parent.isInterface()&gt;
* The constant ${element.getName()}.\n
&lt;#else&gt;
* The ${name}.\n
&lt;/#if&gt; */</VALUE>
</FIELD>
<FIELD>
<KEY>.+</KEY>
<VALUE>/**\n
&lt;#if element.parent.isEnum()&gt;
*${name} ${typeName}.\n
&lt;#else&gt;
* The ${name}.\n
&lt;/#if&gt;*/</VALUE>
</FIELD>
</FIELDS>
</TEMPLATES>
</component>
</project>

View file

@ -2,12 +2,11 @@
<library name="bld"> <library name="bld">
<CLASSES> <CLASSES>
<root url="file://$PROJECT_DIR$/lib/bld" /> <root url="file://$PROJECT_DIR$/lib/bld" />
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1.jar!/" /> <root url="jar://$USER_HOME$/.bld/dist/bld-1.7.0.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/bld" /> <root url="jar://$USER_HOME$/.bld/dist/bld-1.7.0-sources.jar!/" />
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1-sources.jar!/" />
</SOURCES> </SOURCES>
<excluded> <excluded>
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" /> <root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />

View file

@ -7,7 +7,7 @@
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/compile" /> <root url="file://$PROJECT_DIR$/lib/compile" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" /> <jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -8,7 +8,7 @@
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/runtime" /> <root url="file://$PROJECT_DIR$/lib/runtime" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" /> <jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -8,7 +8,7 @@
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/test" /> <root url="file://$PROJECT_DIR$/lib/test" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" /> <jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" />
</library> </library>
</component> </component>

2
.idea/misc.xml generated
View file

@ -9,7 +9,7 @@
<component name="PDMPlugin"> <component name="PDMPlugin">
<option name="customRuleSets"> <option name="customRuleSets">
<list> <list>
<option value="$PROJECT_DIR$/config/pmd.xml" /> <option value="K:\java\semver\config\pmd.xml" />
</list> </list>
</option> </option>
<option name="skipTestSources" value="false" /> <option name="skipTestSources" value="false" />

9
.vscode/launch.json vendored
View file

@ -5,14 +5,7 @@
"type": "java", "type": "java",
"name": "Run Tests", "name": "Run Tests",
"request": "launch", "request": "launch",
"mainClass": "org.junit.platform.console.ConsoleLauncher", "mainClass": "rife.bld.extension.TestNgOperationTest"
"args": [
"--details=verbose",
"--scan-classpath",
"--disable-banner",
"--disable-ansi-colors",
"--exclude-engine=junit-platform-suite",
"--exclude-engine=junit-vintage"]
} }
] ]
} }

10
.vscode/settings.json vendored
View file

@ -3,13 +3,13 @@
"src/main/java", "src/main/java",
"src/main/resources", "src/main/resources",
"src/test/java", "src/test/java",
"src/test/resources", "src/bld/java"
"src/bld/java",
"src/bld/resources"
], ],
"java.configuration.updateBuildConfiguration": "automatic", "java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [ "java.project.referencedLibraries": [
"${HOME}/.bld/dist/bld-2.2.1.jar", "${HOME}/.bld/dist/bld-1.7.0.jar",
"lib/**/*.jar" "lib/compile/*.jar",
"lib/runtime/*.jar",
"lib/test/*.jar"
] ]
} }

View file

@ -1,46 +1,55 @@
# [bld](https://rife2.com/bld) Extension to Run Tests with [TestNG](https://testng.org/) # [Bld](https://rife2.com/bld) Extension to Run Tests with [TestNG](https://testng.org/)
[![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) [![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
[![bld](https://img.shields.io/badge/2.2.1-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld) [![bld](https://img.shields.io/badge/1.7.1-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld)
[![Release](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/releases/com/uwyn/rife2/bld-testng/maven-metadata.xml?color=blue)](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-testng) [![Release](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/releases/com/uwyn/rife2/bld-testng/maven-metadata.xml?color=blue)](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-testng)
[![Snapshot](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/snapshots/com/uwyn/rife2/bld-testng/maven-metadata.xml?label=snapshot)](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-testng) [![Snapshot](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/snapshots/com/uwyn/rife2/bld-testng/maven-metadata.xml?label=snapshot)](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-testng)
[![GitHub CI](https://github.com/rife2/bld-testng/actions/workflows/bld.yml/badge.svg)](https://github.com/rife2/bld-testng/actions/workflows/bld.yml) [![GitHub CI](https://github.com/rife2/bld-testng/actions/workflows/bld.yml/badge.svg)](https://github.com/rife2/bld-testng/actions/workflows/bld.yml)
To install the latest version, add the following to the `lib/bld/bld-wrapper.properties` file: To install, please refer to the [extensions documentation](https://github.com/rife2/bld/wiki/Extensions).
```properties
bld.extension-testng=com.uwyn.rife2:bld-testng
```
For more information, please refer to the [extensions](https://github.com/rife2/bld/wiki/Extensions) documentation.
## Test with TestNG
To run the tests with TestNG, add the following to your build file: To run the tests with TestNG, add the following to your build file:
```java ```java
@Override @BuildCommand(summary = "Run tests with TestNG")
public TestOperation<?, ?> testOperation() { public void testng() throws Exception {
return new TestNgOperation() new TestNgOperation()
.fromProject(this) .fromProject(this)
.packages("com.example"); .packages("com.example")
.execute();
} }
``` ```
```console ```text
./bld compile test ./bld compile testng
``` ```
- [View Examples Project](https://github.com/rife2/bld-testng/tree/master/examples) You could also override the default `test` command:
```java
@BuildCommand(summary = "Run tests with TestNG")
public void test throws Exception {
new TestNgOperation()
.fromProject(this)
.suites("src/test/resources/testng.xml")
.verbose(2)
.execute();
}
```
```
./bld compile test
```
Please check the [TestNgOperation documentation](https://rife2.github.io/bld-testng/rife/bld/extension/TestNgOperation.html#method-summary) for all available configuration options. Please check the [TestNgOperation documentation](https://rife2.github.io/bld-testng/rife/bld/extension/TestNgOperation.html#method-summary) for all available configuration options.
### TestNG Dependency ### TestNG Dependency
Don't forget to add a TestNG `test` dependency to your build file, as it is not provided by the extension. For example: Don't forget to add a TestNG test dependency to your build file, as it is not provided by the extension. For example:
```java ```java
repositories = List.of(MAVEN_CENTRAL); repositories = List.of(MAVEN_CENTRAL);
scope(test).include(dependency("org.testng", "testng", version(7, 11, 0))); scope(test).include(dependency("org.testng", "testng", version(7, 8, 0)));
```
```

View file

@ -7,9 +7,9 @@
<!-- BEST PRACTICES --> <!-- BEST PRACTICES -->
<rule ref="category/java/bestpractices.xml"> <rule ref="category/java/bestpractices.xml">
<exclude name="AvoidPrintStackTrace"/> <exclude name="AvoidPrintStackTrace"/>
<exclude name="JUnit4TestShouldUseTestAnnotation"/>
<exclude name="JUnitTestContainsTooManyAsserts"/>
<exclude name="GuardLogStatement"/> <exclude name="GuardLogStatement"/>
<exclude name="UnitTestContainsTooManyAsserts"/>
<exclude name="UnitTestShouldUseTestAnnotation"/>
</rule> </rule>
<rule ref="category/java/bestpractices.xml/MissingOverride"> <rule ref="category/java/bestpractices.xml/MissingOverride">
@ -24,8 +24,8 @@
<rule ref="category/java/codestyle.xml"> <rule ref="category/java/codestyle.xml">
<exclude name="AtLeastOneConstructor"/> <exclude name="AtLeastOneConstructor"/>
<exclude name="ClassNamingConventions"/> <exclude name="ClassNamingConventions"/>
<exclude name="CommentDefaultAccessModifier"/>
<exclude name="ConfusingTernary"/> <exclude name="ConfusingTernary"/>
<exclude name="CommentDefaultAccessModifier"/>
<exclude name="FieldNamingConventions"/> <exclude name="FieldNamingConventions"/>
<exclude name="LocalVariableCouldBeFinal"/> <exclude name="LocalVariableCouldBeFinal"/>
<exclude name="LongVariable"/> <exclude name="LongVariable"/>
@ -35,9 +35,8 @@
<exclude name="ShortClassName"/> <exclude name="ShortClassName"/>
<exclude name="ShortMethodName"/> <exclude name="ShortMethodName"/>
<exclude name="ShortVariable"/> <exclude name="ShortVariable"/>
<exclude name="UseExplicitTypes"/>
<exclude name="UseUnderscoresInNumericLiterals"/>
<exclude name="UselessParentheses"/> <exclude name="UselessParentheses"/>
<exclude name="UseUnderscoresInNumericLiterals"/>
</rule> </rule>
<rule ref="category/java/codestyle.xml/UnnecessaryImport"> <rule ref="category/java/codestyle.xml/UnnecessaryImport">
@ -53,6 +52,8 @@
<exclude name="AvoidUncheckedExceptionsInSignatures"/> <exclude name="AvoidUncheckedExceptionsInSignatures"/>
<exclude name="CognitiveComplexity"/> <exclude name="CognitiveComplexity"/>
<exclude name="CyclomaticComplexity"/> <exclude name="CyclomaticComplexity"/>
<exclude name="ExcessiveClassLength"/>
<exclude name="ExcessiveMethodLength"/>
<exclude name="ExcessiveParameterList"/> <exclude name="ExcessiveParameterList"/>
<exclude name="ExcessivePublicCount"/> <exclude name="ExcessivePublicCount"/>
<exclude name="GodClass"/> <exclude name="GodClass"/>
@ -106,4 +107,4 @@
<!-- SECURITY --> <!-- SECURITY -->
<rule ref="category/java/security.xml"> <rule ref="category/java/security.xml">
</rule> </rule>
</ruleset> </ruleset>

1
examples/.idea/.name generated
View file

@ -1 +0,0 @@
bld-testng-examples

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BldConfiguration">
<events />
</component>
</project>

View file

@ -2,12 +2,11 @@
<library name="bld"> <library name="bld">
<CLASSES> <CLASSES>
<root url="file://$PROJECT_DIR$/lib/bld" /> <root url="file://$PROJECT_DIR$/lib/bld" />
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1.jar!/" /> <root url="jar://$USER_HOME$/.bld/dist/bld-1.7.0.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/bld" /> <root url="jar://$USER_HOME$/.bld/dist/bld-1.7.0-sources.jar!/" />
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1-sources.jar!/" />
</SOURCES> </SOURCES>
<excluded> <excluded>
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" /> <root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />

View file

@ -7,7 +7,7 @@
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/compile" /> <root url="file://$PROJECT_DIR$/lib/compile" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" /> <jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -8,7 +8,7 @@
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/runtime" /> <root url="file://$PROJECT_DIR$/lib/runtime" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" /> <jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -8,7 +8,7 @@
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/test" /> <root url="file://$PROJECT_DIR$/lib/test" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" /> <jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -3,10 +3,6 @@
<component name="EntryPointsManager"> <component name="EntryPointsManager">
<pattern value="com.example.ExamplesBuild" method="testng" /> <pattern value="com.example.ExamplesBuild" method="testng" />
<pattern value="com.example.ExampleTest" method="testFail" /> <pattern value="com.example.ExampleTest" method="testFail" />
<pattern value="com.example.ExamplesBuild" method="jacoco" />
<pattern value="com.example.ExamplesTest" />
<pattern value="com.example.ExamplesTest" method="foo" />
<pattern value="com.example.ExamplesTest" method="verifyHello" />
</component> </component>
<component name="PDMPlugin"> <component name="PDMPlugin">
<option name="customRuleSets"> <option name="customRuleSets">

View file

@ -5,10 +5,7 @@
"type": "java", "type": "java",
"name": "Run Tests", "name": "Run Tests",
"request": "launch", "request": "launch",
"mainClass": "com.example.ExamplesBuild", "mainClass": "com.example.ExamplesTest"
"args": [
"compile", "test"
]
} }
] ]
} }

View file

@ -3,14 +3,13 @@
"src/main/java", "src/main/java",
"src/main/resources", "src/main/resources",
"src/test/java", "src/test/java",
"src/test/resources", "src/bld/java"
"src/bld/java",
"src/bld/resources",
"src/bld/resources"
], ],
"java.configuration.updateBuildConfiguration": "automatic", "java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [ "java.project.referencedLibraries": [
"${HOME}/.bld/dist/bld-2.2.1.jar", "${HOME}/.bld/dist/bld-1.7.0.jar",
"lib/**/*.jar" "lib/compile/*.jar",
"lib/runtime/*.jar",
"lib/test/*.jar"
] ]
} }

View file

@ -1,11 +0,0 @@
Compile and Run Tests with TestNG
```console
./bld compile test
```
Compile and Generate JaCoCo Reports
```console
./bld compile jacoco
```

Binary file not shown.

View file

@ -1,8 +1,7 @@
bld.downloadExtensionJavadoc=false bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true bld.downloadExtensionSources=true
bld.extensions=com.uwyn.rife2:bld-testng:0.9.0
bld.repositories=RIFE2_SNAPSHOTS,RIFE2_RELEASES,MAVEN_CENTRAL
bld.downloadLocation= bld.downloadLocation=
bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.10-SNAPSHOT
bld.extension-testng=com.uwyn.rife2:bld-testng:1.0.3-SNAPSHOT
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.sourceDirectories= bld.sourceDirectories=
bld.version=2.2.1 bld.version=1.7.1

View file

@ -2,67 +2,32 @@ package com.example;
import rife.bld.BaseProject; import rife.bld.BaseProject;
import rife.bld.BuildCommand; import rife.bld.BuildCommand;
import rife.bld.extension.JacocoReportOperation;
import rife.bld.extension.TestNgOperation; import rife.bld.extension.TestNgOperation;
import rife.bld.operations.TestOperation;
import java.util.List; import java.util.List;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import static rife.bld.dependencies.Repository.MAVEN_CENTRAL; import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
import static rife.bld.dependencies.Scope.test; import static rife.bld.dependencies.Scope.test;
/**
* Example build.
*
* <pre>{@code
* ./bld compile test
* ./bld compile jacoco
* }</pre>
*/
public class ExamplesBuild extends BaseProject { public class ExamplesBuild extends BaseProject {
public ExamplesBuild() { public ExamplesBuild() {
pkg = "com.example"; pkg = "com.example";
name = "Examples"; name = "Examples";
version = version(0, 1, 0); version = version(0, 1, 0);
javaRelease = 17;
downloadSources = true;
autoDownloadPurge = true;
repositories = List.of(MAVEN_CENTRAL); repositories = List.of(MAVEN_CENTRAL);
scope(test).include(dependency("org.testng", "testng", version(7, 8, 0)));
scope(test).include(dependency("org.testng", "testng", version(7, 11, 0)));
} }
public static void main(String[] args) { public static void main(String[] args) {
// Enable detailed logging for the JaCoCo extension
var level = Level.ALL;
var logger = Logger.getLogger("rife.bld.extension");
var consoleHandler = new ConsoleHandler();
consoleHandler.setLevel(level);
logger.addHandler(consoleHandler);
logger.setLevel(level);
logger.setUseParentHandlers(false);
new ExamplesBuild().start(args); new ExamplesBuild().start(args);
} }
@BuildCommand(summary = "Generates Jacoco Reports") @BuildCommand(summary = "Run tests with TestNG")
public void jacoco() throws Exception { public void testng() throws Exception {
new JacocoReportOperation() new TestNgOperation()
.fromProject(this) .fromProject(this)
.packages("com.example")
.execute(); .execute();
} }
}
@Override
public TestOperation<?, ?> testOperation() {
return new TestNgOperation()
.fromProject(this)
.packages("com.example");
}
}

View file

@ -3,16 +3,18 @@ package com.example;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.Test; import org.testng.annotations.Test;
class ExamplesTest { class ExampleTest {
private final ExamplesLib example = new ExamplesLib(); public static void main(String[] args) {
new ExampleTest().verifyHello();
}
@Test @Test
void foo() { void testFail() {
Assert.assertNotEquals(example.getMessage(), "foo"); Assert.fail("failed");
} }
@Test @Test
void verifyHello() { void verifyHello() {
Assert.assertEquals(example.getMessage(), "Hello World!"); Assert.assertTrue(true);
} }
} }

Binary file not shown.

View file

@ -1,8 +1,8 @@
bld.downloadExtensionJavadoc=false bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true bld.downloadExtensionSources=true
bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.2
bld.extension-generated-version=com.uwyn.rife2:bld-generated-version:0.9.1
bld.repositories=RIFE2_SNAPSHOTS,RIFE2_RELEASES,MAVEN_CENTRAL
bld.downloadLocation= bld.downloadLocation=
bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.4
bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.2.1
bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.sourceDirectories= bld.sourceDirectories=
bld.version=2.2.1 bld.version=1.7.1

View file

@ -1,16 +0,0 @@
#!/bin/bash
main="org.testng.TestNG"
new=/tmp/checkcliargs-new
old=/tmp/checkcliargs-old
java -cp "lib/test/*" $main 2>/dev/null >$new
java -cp "examples/lib/test/*" $main 2>/dev/null >$old
if [ "$1" = "-v" ]; then
code --wait --diff $old $new
else
diff $old $new
fi
rm -rf $new $old

View file

@ -1,9 +0,0 @@
#!/bin/bash
java -cp "lib/test/*" org.testng.TestNG 2>/dev/null |\
grep "^ -.*" |\
sed -e "s/ -/-/" -e "s/, -/\n-/" |\
sed "/testRunFactory/d" |\
sort |\
sed '$s/,//' > "src/test/resources/testng-args.txt"

View file

@ -1,17 +1,17 @@
/* /*
* Copyright 2023-2025 the original author or authors. * Copyright 2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* https://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package rife.bld.extension; package rife.bld.extension;
@ -24,7 +24,8 @@ import rife.bld.publish.PublishScm;
import java.util.List; import java.util.List;
import static rife.bld.dependencies.Repository.*; import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
import static rife.bld.dependencies.Repository.RIFE2_RELEASES;
import static rife.bld.dependencies.Scope.compile; import static rife.bld.dependencies.Scope.compile;
import static rife.bld.dependencies.Scope.test; import static rife.bld.dependencies.Scope.test;
import static rife.bld.operations.JavadocOptions.DocLinkOption.NO_MISSING; import static rife.bld.operations.JavadocOptions.DocLinkOption.NO_MISSING;
@ -33,54 +34,44 @@ public class TestNgOperationBuild extends Project {
public TestNgOperationBuild() { public TestNgOperationBuild() {
pkg = "rife.bld.extension"; pkg = "rife.bld.extension";
name = "bld-testng"; name = "bld-testng";
version = version(1, 0, 3, "SNAPSHOT"); version = version(0, 9, 0);
javaRelease = 17; javaRelease = 17;
downloadSources = true; downloadSources = true;
autoDownloadPurge = true; autoDownloadPurge = true;
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES, RIFE2_SNAPSHOTS);
var rife2 = version(1, 7, 0);
scope(compile) scope(compile)
.include(dependency("com.uwyn.rife2", "bld", version(2, 2, 1))); .include(dependency("com.uwyn.rife2", "rife2", rife2))
.include(dependency("com.uwyn.rife2", "bld", version(1, 7, 1)));
scope(test) scope(test)
.include(dependency("org.testng", "testng", version(7, 11, 0))) .include(dependency("org.testng", "testng", version(7, 8, 0)))
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 1))) .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 0)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 1))) .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 0)))
.include(dependency("org.assertj", "assertj-core", version(3, 27, 3))); .include(dependency("org.assertj:assertj-joda-time:2.2.0"));
javadocOperation() javadocOperation()
.javadocOptions() .javadocOptions()
.author()
.docLint(NO_MISSING) .docLint(NO_MISSING)
.link("https://rife2.github.io/bld/") .link("https://rife2.github.io/bld/")
.link("https://rife2.github.io/rife2/"); .link("https://rife2.github.io/rife2/");
publishOperation() publishOperation()
.repository(version.isSnapshot() ? repository("rife2-snapshot") : repository("rife2")) .repository(version.isSnapshot() ? repository("rife2-snapshot") : repository("rife2"))
.repository(repository("github"))
.info() .info()
.groupId("com.uwyn.rife2") .groupId("com.uwyn.rife2")
.artifactId("bld-testng") .artifactId("bld-testng")
.description("bld Extension to execute tests with TestNG") .description("bld Extension to execute tests with TestNG")
.url("https://github.com/rife2/bld-testng") .url("https://github.com/rife2/bld-testng")
.developer(new PublishDeveloper() .developer(new PublishDeveloper().id("ethauvin").name("Erik C. Thauvin").email("erik@thauvin.net")
.id("ethauvin") .url("https://erik.thauvin.net/"))
.name("Erik C. Thauvin") .license(new PublishLicense().name("The Apache License, Version 2.0")
.email("erik@thauvin.net") .url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
.url("https://erik.thauvin.net/") .scm(new PublishScm().connection("scm:git:https://github.com/rife2/bld-testng.git")
)
.license(new PublishLicense()
.name("The Apache License, Version 2.0")
.url("https://www.apache.org/licenses/LICENSE-2.0.txt")
)
.scm(new PublishScm()
.connection("scm:git:https://github.com/rife2/bld-testng.git")
.developerConnection("scm:git:git@github.com:rife2/bld-testng.git") .developerConnection("scm:git:git@github.com:rife2/bld-testng.git")
.url("https://github.com/rife2/bld-testng") .url("https://github.com/rife2/bld-testng"))
)
.signKey(property("sign.key")) .signKey(property("sign.key"))
.signPassphrase(property("sign.passphrase")); .signPassphrase(property("sign.passphrase"));
} }
@ -97,16 +88,4 @@ public class TestNgOperationBuild extends Project {
.ruleSets("config/pmd.xml") .ruleSets("config/pmd.xml")
.execute(); .execute();
} }
}
@Override
public void test() throws Exception {
var os = System.getProperty("os.name");
if (os != null && os.toLowerCase().contains("linux")) {
new ExecOperation()
.fromProject(this)
.command("scripts/cliargs.sh")
.execute();
}
super.test();
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,31 +0,0 @@
/*
* Copyright 2023-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rife.bld.extension;
/**
* Implements the TestNgExample class.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 1.0
*/
@SuppressWarnings({"PMD.TestClassWithoutTestCases", "unused"})
class TestNgExample {
@SuppressWarnings("SameReturnValue")
public String getMessage() {
return "Hello World!";
}
}

View file

@ -1,41 +0,0 @@
/*
* Copyright 2023-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rife.bld.extension;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* Implements the TestNgExampleTest class.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 1.0
*/
@SuppressWarnings("unused")
class TestNgExampleTest {
private final TestNgExample example = new TestNgExample();
@Test
void foo() {
Assert.assertEquals(example.getMessage(), "foo");
}
@Test
void verifyHello() {
Assert.assertEquals(example.getMessage(), "Hello World!");
}
}

View file

@ -1,35 +1,25 @@
/* /*
* Copyright 2023-2025 the original author or authors. * Copyright 2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* https://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package rife.bld.extension; package rife.bld.extension;
import org.assertj.core.api.AutoCloseableSoftAssertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs; import rife.bld.Project; // NOPMD
import org.junit.jupiter.api.condition.OS;
import rife.bld.Project;
import rife.bld.blueprints.BaseProjectBlueprint;
import rife.bld.operations.exceptions.ExitStatusException; import rife.bld.operations.exceptions.ExitStatusException;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
/** /**
@ -46,132 +36,47 @@ class TestNgOperationTest {
@Test @Test
void testAlwaysRunListeners() { void testAlwaysRunListeners() {
var op = new TestNgOperation().alwaysRunListeners(false); var op = new TestNgOperation().alwaysRunListeners(false);
assertThat(op.options().get("-alwaysrunlisteners")).isEqualTo("false"); assertThat(op.options.get("-alwaysrunlisteners")).isEqualTo("false");
op = new TestNgOperation().alwaysRunListeners(true); op = new TestNgOperation().alwaysRunListeners(true);
assertThat(op.options().get("-alwaysrunlisteners")).isEqualTo("true"); assertThat(op.options.get("-alwaysrunlisteners")).isEqualTo("true");
}
@Test
@EnabledOnOs(OS.LINUX)
void testCheckAllParameters() throws IOException {
var args = Files.readAllLines(Paths.get("src", "test", "resources", "testng-args.txt"));
assertThat(args).isNotEmpty();
var params = new TestNgOperation()
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", "examples", "Examples"))
.alwaysRunListeners(true)
.dataProviderThreadCount(1)
.dependencyInjectorFactory("injectorfactory")
.directory("dir")
.excludeGroups("group")
.failWhenEverythingSkipped(true)
.failurePolicy(TestNgOperation.FailurePolicy.SKIP)
.generateResultsPerSuite(true)
.groups("group1", "group2")
.ignoreMissedTestName(true)
.includeAllDataDrivenTestsWhenSkipping(true)
.listener("listener")
.listenerComparator("comparator")
.listenerFactory("factory")
.log(1)
.methodSelectors("selector")
.methods("methods")
.mixed(true)
.objectFactory("objectFactory")
.overrideIncludedMethods("method")
.parallel(TestNgOperation.Parallel.TESTS)
.propagateDataProviderFailureAsTestFailure(true)
.reporter("reporter")
.shareThreadPoolForDataProviders(true)
.spiListenersToSkip("listenter")
.suiteName("name")
.suiteThreadPoolSize(1)
.testClass("class")
.testJar("jar")
.testName("name")
.testNames("names")
.testRunFactory("runFactory")
.threadCount(1)
.threadPoolFactoryClass("poolClass")
.useDefaultListeners(true)
.useGlobalThreadPool(true)
.verbose(1)
.xmlPathInJar("jarPath")
.executeConstructProcessCommandList();
try (var softly = new AutoCloseableSoftAssertions()) {
for (var p : args) {
var found = false;
for (var a : params) {
if (a.startsWith(p)) {
found = true;
break;
}
}
softly.assertThat(found).as(p + " not found.").isTrue();
}
}
} }
@Test @Test
void testClass() { void testClass() {
var op = new TestNgOperation().testClass(FOO, BAR); var op = new TestNgOperation().testClass(FOO, BAR);
assertThat(op.options().get("-testclass")).isEqualTo(String.format("%s,%s", FOO, BAR)); assertThat(op.options.get(TestNgOperation.TEST_CLASS_ARG)).isEqualTo(String.format("%s,%s", FOO, BAR));
new TestNgOperation().testClass(List.of(FOO, BAR));
assertThat(op.options().get("-testclass")).as("as list")
.isEqualTo(String.format("%s,%s", FOO, BAR));
}
@Test
void testClasspath() {
var op = new TestNgOperation().testClasspath(FOO, BAR);
assertThat(op.testClasspath()).containsExactly(BAR, FOO);
} }
@Test @Test
void testDataProviderThreadCount() { void testDataProviderThreadCount() {
var op = new TestNgOperation().dataProviderThreadCount(1); var op = new TestNgOperation().dataProviderThreadCount(1);
assertThat(op.options().get("-dataproviderthreadcount")).isEqualTo("1"); assertThat(op.options.get("-dataproviderthreadcount")).isEqualTo("1");
} }
@Test @Test
void testDependencyInjectorFactory() { void testDependencyInjectorFactory() {
var op = new TestNgOperation().dependencyInjectorFactory(FOO); var op = new TestNgOperation().dependencyInjectorFactory(FOO);
assertThat(op.options().get("-dependencyinjectorfactory")).isEqualTo(FOO); assertThat(op.options.get("-dependencyinjectorfactory")).isEqualTo(FOO);
} }
@Test @Test
void testDirectory() { void testDirectory() {
var foo = new File("FOO");
var op = new TestNgOperation().directory(FOO); var op = new TestNgOperation().directory(FOO);
assertThat(op.options().get("-d")).as("as string").isEqualTo(FOO); assertThat(op.options.get("-d")).isEqualTo(FOO);
op = new TestNgOperation().directory(foo);
assertThat(op.options().get("-d")).as("as file").isEqualTo(foo.getAbsolutePath());
op = new TestNgOperation().directory(foo.toPath());
assertThat(op.options().get("-d")).as("as path").isEqualTo(foo.getAbsolutePath());
} }
@Test @Test
void testExcludeGroups() { void testExcludeGroups() {
var op = new TestNgOperation().excludeGroups(FOO, BAR); var op = new TestNgOperation().excludeGroups(FOO, BAR);
assertThat(op.options().get("-excludegroups")).isEqualTo(String.format("%s,%s", FOO, BAR)); assertThat(op.options.get("-excludegroups")).isEqualTo(String.format("%s,%s", FOO, BAR));
op = new TestNgOperation().excludeGroups(List.of(FOO, BAR));
assertThat(op.options().get("-excludegroups")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
} }
@Test @Test
void testExecute() { void testExecute() {
assertThatThrownBy(() -> assertThatThrownBy(() ->
new TestNgOperation().fromProject(new Project()) new TestNgOperation().fromProject(new Project())
.testClass("rife.bld.extension.TestNgExampleTest") .testClass("rife.bld.extension.TestNgSimpleTest")
.execute()) .execute())
.as("with testClass").isInstanceOf(ExitStatusException.class); .as("with testClass").isInstanceOf(ExitStatusException.class);
@ -183,9 +88,10 @@ class TestNgOperationTest {
assertThatCode(() -> assertThatCode(() ->
new TestNgOperation().fromProject(new Project()) new TestNgOperation().fromProject(new Project())
.methods("rife.bld.extension.TestNgExampleTest.foo") .testClass("rife.bld.extension.TestNgSimpleTest")
.methods("rife.bld.extension.TestNgSimpleTest.verifyHello")
.execute()) .execute())
.as("with methods").isInstanceOf(ExitStatusException.class); .as("with methods").doesNotThrowAnyException();
assertThatCode(() -> assertThatCode(() ->
new TestNgOperation().fromProject(new Project()) new TestNgOperation().fromProject(new Project())
@ -195,329 +101,245 @@ class TestNgOperationTest {
assertThatCode(() -> assertThatCode(() ->
new TestNgOperation().fromProject(new Project()) new TestNgOperation().fromProject(new Project())
.suites("src/test/resources/testng2.xml") .suites("src/test/resources/testng3.xml")
.log(2) .log(2)
.execute()) .execute())
.as("suite 2 - log ").doesNotThrowAnyException(); .as("suite 3").doesNotThrowAnyException();
assertThatCode(() -> assertThatCode(() ->
new TestNgOperation().fromProject(new Project()) new TestNgOperation().fromProject(new Project())
.suites("src/test/resources/testng2.xml") .suites("src/test/resources/testng3.xml")
.testClasspath("lib/test/*", "build/main", "build/test") .testClasspath("lib/test/*", "build/main", "build/test")
.log(2) .log(2)
.execute()) .execute())
.as("with run classpath").doesNotThrowAnyException(); .as("with run classpath").doesNotThrowAnyException();
assertThatCode(() ->
new TestNgOperation().fromProject(new Project())
.suites("src/test/resources/testng2.xml")
.testClasspath(List.of("lib/test/*", "build/main", "build/test"))
.log(2)
.execute())
.as("with run classpath as list").doesNotThrowAnyException();
} }
@Test @Test
void testFailWheneverEverythingSkipped() { void testFailWheneverEverythingSkipped() {
var op = new TestNgOperation().failWhenEverythingSkipped(false); var op = new TestNgOperation().failWhenEverythingSkipped(false);
assertThat(op.options().get("-failwheneverythingskipped")).isEqualTo("false"); assertThat(op.options.get("-failwheneverythingskipped")).isEqualTo("false");
op = new TestNgOperation().failWhenEverythingSkipped(true); op = new TestNgOperation().failWhenEverythingSkipped(true);
assertThat(op.options().get("-failwheneverythingskipped")).isEqualTo("true"); assertThat(op.options.get("-failwheneverythingskipped")).isEqualTo("true");
} }
@Test @Test
void testFailurePolicy() { void testFailurePolicy() {
var op = new TestNgOperation().failurePolicy(TestNgOperation.FailurePolicy.CONTINUE); var op = new TestNgOperation().failurePolicy(TestNgOperation.FailurePolicy.CONTINUE);
assertThat(op.options().get("-configfailurepolicy")).isEqualTo("continue"); assertThat(op.options.get("-configfailurepolicy")).isEqualTo("continue");
op = new TestNgOperation().failurePolicy(TestNgOperation.FailurePolicy.SKIP); op = new TestNgOperation().failurePolicy(TestNgOperation.FailurePolicy.SKIP);
assertThat(op.options().get("-configfailurepolicy")).isEqualTo("skip"); assertThat(op.options.get("-configfailurepolicy")).isEqualTo("skip");
} }
@Test @Test
void testGenerateResultsPerSuite() { void testGenerateResultsPerSuite() {
var op = new TestNgOperation().generateResultsPerSuite(false); var op = new TestNgOperation().generateResultsPerSuite(false);
assertThat(op.options().get("-generateResultsPerSuite")).isEqualTo("false"); assertThat(op.options.get("-generateResultsPerSuite")).isEqualTo("false");
op = new TestNgOperation().generateResultsPerSuite(true); op = new TestNgOperation().generateResultsPerSuite(true);
assertThat(op.options().get("-generateResultsPerSuite")).isEqualTo("true"); assertThat(op.options.get("-generateResultsPerSuite")).isEqualTo("true");
} }
@Test @Test
void testGroups() { void testGroups() {
var op = new TestNgOperation().groups(FOO, BAR); var op = new TestNgOperation().groups(FOO, BAR);
assertThat(op.options().get("-groups")).isEqualTo(String.format("%s,%s", FOO, BAR)); assertThat(op.options.get("-groups")).isEqualTo(String.format("%s,%s", FOO, BAR));
op.groups(List.of("group3", "group4"));
assertThat(op.options().get("-groups")).isEqualTo("group3,group4");
} }
@Test @Test
void testIgnoreMissedTestName() { void testIgnoreMissedTestName() {
var op = new TestNgOperation().ignoreMissedTestName(false); var op = new TestNgOperation().ignoreMissedTestName(false);
assertThat(op.options().get("-ignoreMissedTestNames")).isEqualTo("false"); assertThat(op.options.get("-ignoreMissedTestNames")).isEqualTo("false");
op = new TestNgOperation().ignoreMissedTestName(true); op = new TestNgOperation().ignoreMissedTestName(true);
assertThat(op.options().get("-ignoreMissedTestNames")).isEqualTo("true"); assertThat(op.options.get("-ignoreMissedTestNames")).isEqualTo("true");
} }
@Test @Test
void testIncludeAllDataDrivenTestsWhenSkipping() { void testIncludeAllDataDrivenTestsWhenSkipping() {
var op = new TestNgOperation().includeAllDataDrivenTestsWhenSkipping(false); var op = new TestNgOperation().includeAllDataDrivenTestsWhenSkipping(false);
assertThat(op.options().get("-includeAllDataDrivenTestsWhenSkipping")).isEqualTo("false"); assertThat(op.options.get("-includeAllDataDrivenTestsWhenSkipping")).isEqualTo("false");
op = new TestNgOperation().includeAllDataDrivenTestsWhenSkipping(true); op = new TestNgOperation().includeAllDataDrivenTestsWhenSkipping(true);
assertThat(op.options().get("-includeAllDataDrivenTestsWhenSkipping")).isEqualTo("true"); assertThat(op.options.get("-includeAllDataDrivenTestsWhenSkipping")).isEqualTo("true");
} }
@Test @Test
void testJar() { void testJar() {
var op = new TestNgOperation().testJar(FOO); var op = new TestNgOperation().testJar(FOO);
assertThat(op.options().get("-testjar")).isEqualTo(FOO); assertThat(op.options.get("-testjar")).isEqualTo(FOO);
} }
@Test @Test
void testJunit() { void testJunit() {
var op = new TestNgOperation().jUnit(false); var op = new TestNgOperation().jUnit(false);
assertThat(op.options().get("-junit")).isEqualTo("false"); assertThat(op.options.get("-junit")).isEqualTo("false");
op = new TestNgOperation().jUnit(true); op = new TestNgOperation().jUnit(true);
assertThat(op.options().get("-junit")).isEqualTo("true"); assertThat(op.options.get("-junit")).isEqualTo("true");
} }
@Test @Test
void testListener() { void testListener() {
var ops = new TestNgOperation().listener(FOO, BAR); var ops = new TestNgOperation().listener(FOO, BAR);
assertThat(ops.options().get("-listener")).isEqualTo(String.format("%s,%s", FOO, BAR)); assertThat(ops.options.get("-listener")).isEqualTo(String.format("%s,%s", FOO, BAR));
ops = new TestNgOperation().listener(List.of(FOO, BAR));
assertThat(ops.options().get("-listener")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
} }
@Test @Test
void testMethodDetectors() { void testMethodDetectors() {
var op = new TestNgOperation().methodSelectors(FOO, BAR); var op = new TestNgOperation().methodSelectors(FOO, BAR);
assertThat(op.options().get("-methodselectors")).isEqualTo(String.format("%s,%s", FOO, BAR)); assertThat(op.options.get("-methodselectors")).isEqualTo(String.format("%s,%s", FOO, BAR));
op = new TestNgOperation().methodSelectors(List.of(FOO, BAR));
assertThat(op.options().get("-methodselectors")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
} }
@Test @Test
void testMethods() { void testMethods() {
var op = new TestNgOperation().methods(FOO, BAR); var op = new TestNgOperation().methods(FOO, BAR);
assertThat(op.methods()).containsExactly(BAR, FOO); assertThat(op.options.get("-methods")).isEqualTo(String.format("%s,%s", FOO, BAR));
new TestNgOperation().methods(List.of(FOO, BAR));
assertThat(op.methods()).containsExactly(BAR, FOO);
} }
@Test @Test
void testMixed() { void testMixed() {
var op = new TestNgOperation().mixed(false); var op = new TestNgOperation().mixed(false);
assertThat(op.options().get("-mixed")).isEqualTo("false"); assertThat(op.options.get("-mixed")).isEqualTo("false");
op = new TestNgOperation().mixed(true); op = new TestNgOperation().mixed(true);
assertThat(op.options().get("-mixed")).isEqualTo("true"); assertThat(op.options.get("-mixed")).isEqualTo("true");
} }
@Test @Test
void testName() { void testName() {
var op = new TestNgOperation().testName(FOO); var op = new TestNgOperation().testName(FOO);
assertThat(op.options().get("-testname")).isEqualTo("\"" + FOO + '\"'); assertThat(op.options.get("-testname")).isEqualTo("\"" + FOO + '\"');
} }
@Test @Test
void testNames() { void testNames() {
var ops = new TestNgOperation().testNames(FOO, BAR); var ops = new TestNgOperation().testNames(FOO, BAR);
assertThat(ops.options().get("-testnames")).isEqualTo(String.format("\"%s\",\"%s\"", FOO, BAR)); assertThat(ops.options.get("-testnames")).isEqualTo(String.format("\"%s\",\"%s\"", FOO, BAR));
new TestNgOperation().testNames(List.of(FOO, BAR));
assertThat(ops.options().get("-testnames")).as("as list").isEqualTo(String.format("\"%s\",\"%s\"", FOO, BAR));
} }
@Test @Test
void testObjectFactory() { void testObjectFactory() {
var ops = new TestNgOperation().objectFactory(FOO, BAR); var ops = new TestNgOperation().objectFactory(FOO, BAR);
assertThat(ops.options().get("-objectfactory")).isEqualTo(String.format("%s,%s", FOO, BAR)); assertThat(ops.options.get("-objectfactory")).isEqualTo(String.format("%s,%s", FOO, BAR));
ops = new TestNgOperation().objectFactory(List.of(FOO, BAR));
assertThat(ops.options().get("-objectfactory")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
} }
@Test @Test
void testOverrideIncludedMethods() { void testOverrideIncludedMethods() {
var ops = new TestNgOperation().overrideIncludedMethods(FOO, BAR); var ops = new TestNgOperation().overrideIncludedMethods(FOO, BAR);
assertThat(ops.options().get("-overrideincludedmethods")).isEqualTo(String.format("%s,%s", FOO, BAR)); assertThat(ops.options.get("-overrideincludedmethods")).isEqualTo(String.format("%s,%s", FOO, BAR));
ops = new TestNgOperation().overrideIncludedMethods(List.of(FOO, BAR));
assertThat(ops.options().get("-overrideincludedmethods")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
} }
@Test @Test
void testPackages() { void testPackages() {
var op = new TestNgOperation().packages(FOO, BAR); var op = new TestNgOperation().packages(FOO, BAR);
assertThat(op.packages()).contains(FOO).contains(BAR); assertThat(op.packages).contains(FOO).contains(BAR);
op = new TestNgOperation().packages(List.of(FOO, BAR));
assertThat(op.packages()).as("as list").contains(FOO).contains(BAR);
} }
@Test @Test
void testParallel() { void testParallel() {
var op = new TestNgOperation().parallel(TestNgOperation.Parallel.TESTS); var op = new TestNgOperation().parallel(TestNgOperation.Parallel.TESTS);
assertThat(op.options().get("-parallel")).isEqualTo("tests"); assertThat(op.options.get("-parallel")).isEqualTo("tests");
op = new TestNgOperation().parallel(TestNgOperation.Parallel.METHODS); op = new TestNgOperation().parallel(TestNgOperation.Parallel.METHODS);
assertThat(op.options().get("-parallel")).isEqualTo("methods"); assertThat(op.options.get("-parallel")).isEqualTo("methods");
op = new TestNgOperation().parallel(TestNgOperation.Parallel.CLASSES); op = new TestNgOperation().parallel(TestNgOperation.Parallel.CLASSES);
assertThat(op.options().get("-parallel")).isEqualTo("classes"); assertThat(op.options.get("-parallel")).isEqualTo("classes");
} }
@Test @Test
void testPort() { void testPort() {
var op = new TestNgOperation().port(1); var op = new TestNgOperation().port(1);
assertThat(op.options().get("-port")).isEqualTo("1"); assertThat(op.options.get("-port")).isEqualTo("1");
} }
@Test @Test
void testPropagateDataProviderFailureAsTestFailure() { void testPropagateDataProviderFailureAsTestFailure() {
var op = new TestNgOperation().propagateDataProviderFailureAsTestFailure(false); var op = new TestNgOperation().propagateDataProviderFailureAsTestFailure(false);
assertThat(op.options().get("-propagateDataProviderFailureAsTestFailure")).isEqualTo("false"); assertThat(op.options.get("-propagateDataProviderFailureAsTestFailure")).isEqualTo("false");
op = new TestNgOperation().propagateDataProviderFailureAsTestFailure(true); op = new TestNgOperation().propagateDataProviderFailureAsTestFailure(true);
assertThat(op.options().get("-propagateDataProviderFailureAsTestFailure")).isEqualTo("true"); assertThat(op.options.get("-propagateDataProviderFailureAsTestFailure")).isEqualTo("true");
} }
@Test @Test
void testReported() { void testReported() {
var op = new TestNgOperation().reporter(FOO); var op = new TestNgOperation().reporter(FOO);
assertThat(op.options().get("-reporter")).isEqualTo(FOO); assertThat(op.options.get("-reporter")).isEqualTo(FOO);
} }
@Test @Test
void testRunFactory() { void testRunFactory() {
var op = new TestNgOperation().testRunFactory(FOO); var op = new TestNgOperation().testRunFactory(FOO);
assertThat(op.options().get("-testrunfactory")).isEqualTo(FOO); assertThat(op.options.get("-testrunfactory")).isEqualTo(FOO);
}
@Test
void testShareThreadPoolForDataProviders() {
var op = new TestNgOperation().shareThreadPoolForDataProviders(true);
assertThat(op.options().get("-shareThreadPoolForDataProviders")).isEqualTo("true");
op = new TestNgOperation().shareThreadPoolForDataProviders(false);
assertThat(op.options().get("-shareThreadPoolForDataProviders")).isNull();
} }
@Test @Test
void testSourceDir() { void testSourceDir() {
var foo = new File(FOO);
var bar = new File(BAR);
var foobar = String.format("%s;%s", FOO, BAR);
var op = new TestNgOperation().sourceDir(FOO, BAR); var op = new TestNgOperation().sourceDir(FOO, BAR);
assertThat(op.options().get("-sourcedir")).as("String...").isEqualTo(foobar); assertThat(op.options.get("-sourcedir")).isEqualTo(String.format("%s;%s", FOO, BAR));
op = new TestNgOperation().sourceDir(List.of(FOO, BAR));
assertThat(op.options().get("-sourcedir")).as("List(String...)").isEqualTo(foobar);
foobar = String.format("%s;%s", foo.getAbsolutePath(), bar.getAbsolutePath());
op = new TestNgOperation().sourceDir(foo, bar);
assertThat(op.options().get("-sourcedir")).as("File...").isEqualTo(foobar);
op = new TestNgOperation().sourceDirFiles(List.of(foo, bar));
assertThat(op.options().get("-sourcedir")).as("List(String...)").isEqualTo(foobar);
op = new TestNgOperation().sourceDir(foo.toPath(), bar.toPath());
assertThat(op.options().get("-sourcedir")).as("Path...").isEqualTo(foobar);
op = new TestNgOperation().sourceDirPaths(List.of(foo.toPath(), bar.toPath()));
assertThat(op.options().get("-sourcedir")).as("List(Path...)").isEqualTo(foobar);
} }
@Test @Test
void testSpiListenersToSkip() { void testSpiListenersToSkip() {
var ops = new TestNgOperation().spiListenersToSkip(FOO, BAR); var ops = new TestNgOperation().spiListenersToSkip(FOO, BAR);
assertThat(ops.options().get("-spilistenerstoskip")).isEqualTo(String.format("%s,%s", FOO, BAR)); assertThat(ops.options.get("-spilistenerstoskip")).isEqualTo(String.format("%s,%s", FOO, BAR));
ops = new TestNgOperation().spiListenersToSkip(List.of(FOO, BAR));
assertThat(ops.options().get("-spilistenerstoskip")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
} }
@Test @Test
void testSuiteName() { void testSuiteName() {
var op = new TestNgOperation().suiteName(FOO); var op = new TestNgOperation().suiteName(FOO);
assertThat(op.options().get("-suitename")).isEqualTo("\"" + FOO + '\"'); assertThat(op.options.get("-suitename")).isEqualTo("\"" + FOO + '\"');
} }
@Test @Test
void testSuiteThreadPoolSize() { void testSuiteThreadPoolSize() {
var op = new TestNgOperation().suiteThreadPoolSize(1); var op = new TestNgOperation().suiteThreadPoolSize(1);
assertThat(op.options().get("-suitethreadpoolsize")).isEqualTo("1"); assertThat(op.options.get("-suitethreadpoolsize")).isEqualTo("1");
} }
@Test @Test
void testSuites() { void testSuites() {
var op = new TestNgOperation().suites(FOO, BAR); var op = new TestNgOperation().suites(FOO, BAR);
assertThat(op.suites()).contains(FOO).contains(BAR); assertThat(op.suites).contains(FOO).contains(BAR);
op = new TestNgOperation().suites(List.of(FOO, BAR));
assertThat(op.suites()).as("as list").contains(FOO).contains(BAR);
} }
@Test @Test
void testThreadCount() { void testThreadCount() {
var op = new TestNgOperation().threadCount(1); var op = new TestNgOperation().threadCount(1);
assertThat(op.options().get("-threadcount")).isEqualTo("1"); assertThat(op.options.get("-threadcount")).isEqualTo("1");
} }
@Test @Test
void testThreadPoolFactoryClass() { void testThreadPoolFactoryClass() {
var op = new TestNgOperation().threadPoolFactoryClass(FOO); var op = new TestNgOperation().threadPoolFactoryClass(FOO);
assertThat(op.options().get("-threadpoolfactoryclass")).isEqualTo(FOO); assertThat(op.options.get("-threadpoolfactoryclass")).isEqualTo(FOO);
} }
@Test @Test
void testUseDefaultListeners() { void testUseDefaultListeners() {
var op = new TestNgOperation().useDefaultListeners(false); var op = new TestNgOperation().useDefaultListeners(false);
assertThat(op.options().get("-usedefaultlisteners")).isEqualTo("false"); assertThat(op.options.get("-usedefaultlisteners")).isEqualTo("false");
op = new TestNgOperation().useDefaultListeners(true); op = new TestNgOperation().useDefaultListeners(true);
assertThat(op.options().get("-usedefaultlisteners")).isEqualTo("true"); assertThat(op.options.get("-usedefaultlisteners")).isEqualTo("true");
}
@Test
void testUseGlobalThreadPool() {
var op = new TestNgOperation().useGlobalThreadPool(true);
assertThat(op.options().get("-useGlobalThreadPool")).isEqualTo("true");
op = new TestNgOperation().useGlobalThreadPool(false);
assertThat(op.options().get("-useGlobalThreadPool")).isNull();
} }
@Test @Test
void testVerbose() { void testVerbose() {
var op = new TestNgOperation().log(1); var op = new TestNgOperation().log(1);
assertThat(op.options().get("-log")).isEqualTo("1"); assertThat(op.options.get("-log")).isEqualTo("1");
op = new TestNgOperation().verbose(1); op = new TestNgOperation().verbose(1);
assertThat(op.options().get("-verbose")).isEqualTo("1"); assertThat(op.options.get("-verbose")).isEqualTo("1");
} }
@Test @Test
void testXmlPathInJar() { void testXmlPathInJar() {
var foo = new File(FOO);
var op = new TestNgOperation().xmlPathInJar(FOO); var op = new TestNgOperation().xmlPathInJar(FOO);
assertThat(op.options().get("-xmlpathinjar")).as("as string").isEqualTo(FOO); assertThat(op.options.get("-xmlpathinjar")).isEqualTo(FOO);
op = new TestNgOperation().xmlPathInJar(foo);
assertThat(op.options().get("-xmlpathinjar")).as("as file").isEqualTo(foo.getAbsolutePath());
op = new TestNgOperation().xmlPathInJar(foo.toPath());
assertThat(op.options().get("-xmlpathinjar")).as("as path").isEqualTo(foo.getAbsolutePath());
} }
} }

View file

@ -0,0 +1,37 @@
/*
* Copyright 2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rife.bld.extension;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* Implements the TestNgSimpleTest class.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 1.0
*/
class TestNgSimple2Test {
public static void main(String[] args) {
new TestNgSimple2Test().verifyHello();
}
@Test
void verifyHello() {
Assert.assertTrue(true);
}
}

View file

@ -0,0 +1,42 @@
/*
* Copyright 2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rife.bld.extension;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* Implements the TestNgSimpleTest class.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 1.0
*/
class TestNgSimpleTest {
public static void main(String[] args) {
new TestNgSimpleTest().verifyHello();
}
@Test
void testFail() {
Assert.fail("failed");
}
@Test
void verifyHello() {
Assert.assertTrue(true);
}
}

View file

@ -1,38 +0,0 @@
-alwaysrunlisteners
-configfailurepolicy
-d
-dataproviderthreadcount
-dependencyinjectorfactory
-excludegroups
-failwheneverythingskipped
-generateResultsPerSuite
-groups
-ignoreMissedTestNames
-includeAllDataDrivenTestsWhenSkipping
-listener
-listenercomparator
-listenerfactory
-log
-methods
-methodselectors
-mixed
-objectfactory
-overrideincludedmethods
-parallel
-propagateDataProviderFailureAsTestFailure
-reporter
-shareThreadPoolForDataProviders
-spilistenerstoskip
-suitename
-suitethreadpoolsize
-testclass
-testjar
-testname
-testnames
-testrunfactory
-threadcount
-threadpoolfactoryclass
-usedefaultlisteners
-useGlobalThreadPool
-verbose
-xmlpathinjar

View file

@ -2,11 +2,7 @@
<suite name="test suite 1" verbose="2"> <suite name="test suite 1" verbose="2">
<test name="simple test"> <test name="simple test">
<classes> <classes>
<class name="rife.bld.extension.TestNgExample"/> <class name="rife.bld.extension.TestNgSimpleTest"/>
<methods>
<exclude name="foo"/>
</methods>
</class>
</classes> </classes>
</test> </test>
</suite> </suite>

View file

@ -2,9 +2,9 @@
<suite name="test suite 2" verbose="1"> <suite name="test suite 2" verbose="1">
<test name="exclude fail"> <test name="exclude fail">
<classes> <classes>
<class name="rife.bld.extension.TestNgExampleTest"> <class name="rife.bld.extension.TestNgSimpleTest">
<methods> <methods>
<exclude name="foo"/> <exclude name="testFail"/>
</methods> </methods>
</class> </class>
</classes> </classes>

View file

@ -0,0 +1,13 @@
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" >
<suite name="test suite 3">
<test name="test 2 classes">
<classes>
<class name="rife.bld.extension.TestNgSimpleTest">
<methods>
<exclude name="testFail"/>
</methods>
</class>
<class name="rife.bld.extension.TestNgSimple2Test"/>
</classes>
</test>
</suite>