Skip to content

Commit c5ed091

Browse files
authored
Merge pull request #159 from utPLSQL/feature/add_tags
Feature/add tags
2 parents 5b99f36 + 8fd769a commit c5ed091

File tree

7 files changed

+34
-4
lines changed

7 files changed

+34
-4
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ env:
3131
- UTPLSQL_VERSION="v3.1.2"
3232
- UTPLSQL_VERSION="v3.1.3"
3333
- UTPLSQL_VERSION="v3.1.6"
34+
- UTPLSQL_VERSION="v3.1.7"
3435
- UTPLSQL_VERSION="develop"
3536
UTPLSQL_FILE="utPLSQL"
3637

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ utplsql run "my/Username"/"myP@ssword"@connectstring
102102
Both formats can be mixed in the list.
103103
If only schema is provided, then all suites owner by that schema are executed.
104104
If -p is omitted, the current schema is used.
105+
106+
--tags=tags - A comma separated list of tags to run.
107+
Format: --tags=tag1[,tag2[,tag3]]
105108
106109
-f=format - A reporter to be used for reporting.
107110
(--format) If no -f option is provided, the default ut_documentation_reporter is used.

src/main/java/org/utplsql/cli/RunAction.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ TestRunner newTestRunner(List<Reporter> reporterList) {
163163
.includeObjects(Arrays.asList(config.getIncludePackages()))
164164
.excludeObjects(Arrays.asList(config.getExcludePackages()))
165165
.randomTestOrder(config.isRandomTestOrder())
166-
.randomTestOrderSeed(config.getRandomTestOrderSeed());
166+
.randomTestOrderSeed(config.getRandomTestOrderSeed())
167+
.addTags(Arrays.asList(config.getTags()));
167168
}
168169

169170
private void outputMainInformation() {

src/main/java/org/utplsql/cli/RunPicocliCommand.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public class RunPicocliCommand implements IRunCommand {
2323
"-p=[schema|schema:[suite ...][.test]|schema[.suite ...][.test]")
2424
private List<String> paths = new ArrayList<>();
2525

26+
@Option(names = {"--tags"},
27+
description = "comma-separated list of tags to run",
28+
split = ",")
29+
private List<String> tags = new ArrayList<>();
30+
2631

2732
@Option(
2833
names = {"-c", "--color"},
@@ -232,7 +237,8 @@ public RunCommandConfig getRunCommandConfig() {
232237
timeoutInMinutes,
233238
enableDbmsOutput,
234239
randomTestOrder,
235-
randomTestOrderSeed);
240+
randomTestOrderSeed,
241+
tags.toArray(new String[0]));
236242
}
237243

238244
private RunAction getRunAction() {

src/main/java/org/utplsql/cli/config/RunCommandConfig.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ public class RunCommandConfig extends ConnectionConfig {
2121
private boolean dbmsOutput = false;
2222
private boolean randomTestOrder = false;
2323
private final Integer randomTestOrderSeed;
24+
private final String[] tags;
2425

25-
@ConstructorProperties({"connectString", "suitePaths", "reporters", "outputAnsiColor", "failureExitCode", "skipCompatibilityCheck", "includePackages", "excludePackages", "sourceMapping", "testMapping", "logConfigLevel", "timeoutInMinutes", "dbmsOutput", "randomTestOrder", "randomTestOrderSeed"})
26-
public RunCommandConfig(String connectString, String[] suitePaths, ReporterConfig[] reporters, boolean outputAnsiColor, Integer failureExitCode, boolean skipCompatibilityCheck, String[] includePackages, String[] excludePackages, FileMapperConfig sourceMapping, FileMapperConfig testMapping, ConfigLevel logConfigLevel, Integer timeoutInMinutes, boolean dbmsOutput, boolean randomTestOrder, Integer randomTestOrderSeed) {
26+
@ConstructorProperties({"connectString", "suitePaths", "reporters", "outputAnsiColor", "failureExitCode", "skipCompatibilityCheck", "includePackages", "excludePackages", "sourceMapping", "testMapping", "logConfigLevel", "timeoutInMinutes", "dbmsOutput", "randomTestOrder", "randomTestOrderSeed", "tags"})
27+
public RunCommandConfig(String connectString, String[] suitePaths, ReporterConfig[] reporters, boolean outputAnsiColor, Integer failureExitCode, boolean skipCompatibilityCheck, String[] includePackages, String[] excludePackages, FileMapperConfig sourceMapping, FileMapperConfig testMapping, ConfigLevel logConfigLevel, Integer timeoutInMinutes, boolean dbmsOutput, boolean randomTestOrder, Integer randomTestOrderSeed, String[] tags) {
2728
super(connectString);
2829
this.suitePaths = suitePaths;
2930
this.reporters = reporters;
@@ -39,12 +40,17 @@ public RunCommandConfig(String connectString, String[] suitePaths, ReporterConfi
3940
this.dbmsOutput = dbmsOutput;
4041
this.randomTestOrder = randomTestOrder;
4142
this.randomTestOrderSeed = randomTestOrderSeed;
43+
this.tags = tags;
4244
}
4345

4446
public String[] getSuitePaths() {
4547
return suitePaths;
4648
}
4749

50+
public String[] getTags() {
51+
return tags;
52+
}
53+
4854
public ReporterConfig[] getReporters() {
4955
return reporters;
5056
}

src/test/java/org/utplsql/cli/PicocliRunCommandTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ void runCommandAllArguments() throws Exception {
2020
RunCommandConfig config = parseForConfig("run",
2121
TestHelper.getConnectionString(),
2222
"-p=app.betwnstr,app.basic",
23+
"--tags=tag1,tag.2",
2324
"-d",
2425
"-c",
2526
"-q",
@@ -51,6 +52,7 @@ void runCommandAllArguments() throws Exception {
5152

5253
assertNotNull(config.getConnectString());
5354
assertThat( config.getSuitePaths(), is(new String[]{"app.betwnstr", "app.basic"}));
55+
assertThat( config.getTags(), is(new String[]{"tag1", "tag.2"}));
5456
assertTrue( config.isOutputAnsiColor() );
5557
assertEquals( LoggerConfiguration.ConfigLevel.NONE, config.getLogConfigLevel());
5658
assertEquals( 10, config.getFailureExitCode());

src/test/java/org/utplsql/cli/RunCommandArgumentsTest.java

+11
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public void allArgumentsAreRecognized() {
1717
"-f=ut_sonar_test_reporter",
1818
"-o=sonar_result.xml",
1919
"-s",
20+
"--tags=tag1,tag2",
2021
"-d",
2122
"-c",
2223
"--failure-exit-code=10",
@@ -53,4 +54,14 @@ void multiplePaths() {
5354
assertThat( testRunner.getOptions().pathList, contains("app.test_betwnstr", "app.test_award_bonus") );
5455

5556
}
57+
58+
@Test
59+
void provideTags() {
60+
IRunCommand runCmd = TestHelper.createRunCommand(TestHelper.getConnectionString(),
61+
"--tags=tag1,tag.2"
62+
);
63+
64+
TestRunner testRunner = runCmd.newTestRunner(new ArrayList<>());
65+
assertThat( testRunner.getOptions().tags, contains("tag1", "tag.2") );
66+
}
5667
}

0 commit comments

Comments
 (0)