Compare commits

..

No commits in common. "4d4479bf238470ff15dc693e459a00f429a1e265" and "b9e97142553c040ab46e50c4b300d86fa376969c" have entirely different histories.

10 changed files with 49 additions and 48 deletions

View file

@ -12,12 +12,12 @@ jobs:
steps:
- name: Checkout source repository
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: ${{ matrix.java-version }}

View file

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

View file

@ -1,5 +1,6 @@
# [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)
[![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/1.9.0-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld)
@ -12,11 +13,29 @@ To install, please refer to the [extensions documentation](https://github.com/ri
To run the tests with TestNG, add the following to your build file:
```java
@Override
public TestOperation<?, ?> testOperation() {
return new TestNgOperation()
.fromProject(this)
.packages("com.example");
@BuildCommand(summary = "Tests the project with TestNG")
public void testng() throws Exception {
new TestNgOperation()
.fromProject(this)
.packages("com.example")
.execute();
}
```
```console
./bld compile testng
```
You could also override the default `test` command:
```java
@BuildCommand(summary = "Tests the project with TestNG")
public void test throws Exception {
new TestNgOperation()
.fromProject(this)
.suites("src/test/resources/testng.xml")
.verbose(2)
.execute();
}
```

View file

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

View file

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

View file

@ -1,7 +1,6 @@
bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true
bld.extensions=com.uwyn.rife2:bld-testng:0.9.5
bld.extension.jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.5
bld.extensions=com.uwyn.rife2:bld-testng:0.9.4
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.downloadLocation=
bld.sourceDirectories=

View file

@ -2,11 +2,8 @@ package com.example;
import rife.bld.BaseProject;
import rife.bld.BuildCommand;
import rife.bld.extension.JacocoReportOperation;
import rife.bld.extension.TestNgOperation;
import rife.bld.operations.TestOperation;
import java.io.IOException;
import java.util.List;
import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
@ -16,29 +13,20 @@ import static rife.bld.dependencies.Scope.test;
* Example build.
*
* <ul style="list-style-type:none">
* <li>{@code ./bld compile test}</li>
* <li>{@code ./bld compile jacoco}</li>
* <li>./bld compile test</li>
* </ul>
*/
public class ExamplesBuild extends BaseProject {
@Override
public TestOperation<?, ?> testOperation() {
return new TestNgOperation()
.fromProject(this)
.packages("com.example");
}
public ExamplesBuild() {
pkg = "com.example";
name = "Examples";
version = version(0, 1, 0);
javaRelease = 17;
downloadSources = true;
autoDownloadPurge = true;
repositories = List.of(MAVEN_CENTRAL);
scope(test).include(dependency("org.testng", "testng", version(7, 9, 0)));
}
@ -46,10 +34,11 @@ public class ExamplesBuild extends BaseProject {
new ExamplesBuild().start(args);
}
@BuildCommand(summary = "Generates Jacoco Reports")
public void jacoco() throws IOException {
new JacocoReportOperation()
@BuildCommand(summary = "Tests the project with TestNG")
public void test() throws Exception {
new TestNgOperation()
.fromProject(this)
.packages("com.example")
.execute();
}
}

View file

@ -1,6 +1,6 @@
bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true
bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.8
bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.7
bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.downloadLocation=
bld.sourceDirectories=

View file

@ -34,7 +34,7 @@ public class TestNgOperationBuild extends Project {
public TestNgOperationBuild() {
pkg = "rife.bld.extension";
name = "bld-testng";
version = version(0, 9, 5);
version = version(0, 9, 4);
javaRelease = 17;
downloadSources = true;
@ -76,7 +76,7 @@ public class TestNgOperationBuild extends Project {
.license(
new PublishLicense()
.name("The Apache License, Version 2.0")
.url("https://www.apache.org/licenses/LICENSE-2.0.txt")
.url("http://www.apache.org/licenses/LICENSE-2.0.txt")
)
.scm(
new PublishScm()

View file

@ -17,7 +17,7 @@
package rife.bld.extension;
import rife.bld.BaseProject;
import rife.bld.operations.TestOperation;
import rife.bld.operations.AbstractProcessOperation;
import java.io.File;
import java.io.IOException;
@ -37,7 +37,7 @@ import java.util.stream.Collectors;
* @since 1.0
*/
@SuppressWarnings("PMD.TestClassWithoutTestCases")
public class TestNgOperation extends TestOperation<TestNgOperation, List<String>> {
public class TestNgOperation extends AbstractProcessOperation<TestNgOperation> {
private static final Logger LOGGER = Logger.getLogger(TestNgOperation.class.getName());
/**
* The run options.
@ -151,12 +151,11 @@ public class TestNgOperation extends TestOperation<TestNgOperation, List<String>
}
if (!options.containsKey("-d")) {
options.put("-d", Path.of(project.buildDirectory().getPath(), "test-output").toString());
options.put("d", Path.of(project.buildDirectory().getPath(), "test-output").toString());
}
final List<String> args = new ArrayList<>();
args.add(javaTool());
args.addAll(this.javaOptions());
args.add("-cp");
if (testClasspath.isEmpty()) {