Skip to content

Commit

Permalink
Read parameters from resource file
Browse files Browse the repository at this point in the history
  • Loading branch information
ethauvin committed May 28, 2024
1 parent b0cf0f5 commit 0a869da
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 46 deletions.
7 changes: 6 additions & 1 deletion cliargs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ TMP=/tmp/cliargs

java -cp "lib/test/*" $MAIN >$TMP 2>/dev/null

cat $TMP | grep "^ -.*" | sed -e "s/ -/-/" -e "s/^-/\"-/" -e "s/$/\",/" -e "s/, -/\",\n\"-/" | sed "/testRunFactory/d" | sort | sed '$s/,//'
cat $TMP |\
grep "^ -.*" |\
sed -e "s/ -/-/" -e "s/, -/\n-/" |\
sed "/testRunFactory/d" |\
sort |\
sed '$s/,//' > "src/test/resources/testng-args.txt"

rm -rf $TMP
54 changes: 9 additions & 45 deletions src/test/java/rife/bld/extension/TestNgOperationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
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.*;
Expand All @@ -47,49 +50,10 @@ void testAlwaysRunListeners() {
}

@Test
void testCheckAllParameters() {
var params = List.of(
"-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"
);

var args = new TestNgOperation()
void testCheckAllParameters() throws IOException {
var args = Files.readAllLines(Paths.get("src", "test", "resources", "testng-args.txt"));

var params = new TestNgOperation()
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", "Examples"))
.alwaysRunListeners(true)
.dataProviderThreadCount(1)
Expand Down Expand Up @@ -131,9 +95,9 @@ void testCheckAllParameters() {
.xmlPathInJar("jarPath")
.executeConstructProcessCommandList();

for (var p : params) {
for (var p : args) {
var found = false;
for (var a : args) {
for (var a : params) {
if (a.startsWith(p)) {
found = true;
break;
Expand Down
38 changes: 38 additions & 0 deletions src/test/resources/testng-args.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-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

0 comments on commit 0a869da

Please sign in to comment.