Skip to content

Feature/add tags #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ env:
- UTPLSQL_VERSION="v3.1.2"
- UTPLSQL_VERSION="v3.1.3"
- UTPLSQL_VERSION="v3.1.6"
- UTPLSQL_VERSION="v3.1.7"
- UTPLSQL_VERSION="develop"
UTPLSQL_FILE="utPLSQL"

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ utplsql run "my/Username"/"myP@ssword"@connectstring
Both formats can be mixed in the list.
If only schema is provided, then all suites owner by that schema are executed.
If -p is omitted, the current schema is used.

--tags=tags - A comma separated list of tags to run.
Format: --tags=tag1[,tag2[,tag3]]

-f=format - A reporter to be used for reporting.
(--format) If no -f option is provided, the default ut_documentation_reporter is used.
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/utplsql/cli/RunAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ TestRunner newTestRunner(List<Reporter> reporterList) {
.includeObjects(Arrays.asList(config.getIncludePackages()))
.excludeObjects(Arrays.asList(config.getExcludePackages()))
.randomTestOrder(config.isRandomTestOrder())
.randomTestOrderSeed(config.getRandomTestOrderSeed());
.randomTestOrderSeed(config.getRandomTestOrderSeed())
.addTags(Arrays.asList(config.getTags()));
}

private void outputMainInformation() {
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/org/utplsql/cli/RunPicocliCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public class RunPicocliCommand implements IRunCommand {
"-p=[schema|schema:[suite ...][.test]|schema[.suite ...][.test]")
private List<String> paths = new ArrayList<>();

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


@Option(
names = {"-c", "--color"},
Expand Down Expand Up @@ -232,7 +237,8 @@ public RunCommandConfig getRunCommandConfig() {
timeoutInMinutes,
enableDbmsOutput,
randomTestOrder,
randomTestOrderSeed);
randomTestOrderSeed,
tags.toArray(new String[0]));
}

private RunAction getRunAction() {
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/org/utplsql/cli/config/RunCommandConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ public class RunCommandConfig extends ConnectionConfig {
private boolean dbmsOutput = false;
private boolean randomTestOrder = false;
private final Integer randomTestOrderSeed;
private final String[] tags;

@ConstructorProperties({"connectString", "suitePaths", "reporters", "outputAnsiColor", "failureExitCode", "skipCompatibilityCheck", "includePackages", "excludePackages", "sourceMapping", "testMapping", "logConfigLevel", "timeoutInMinutes", "dbmsOutput", "randomTestOrder", "randomTestOrderSeed"})
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) {
@ConstructorProperties({"connectString", "suitePaths", "reporters", "outputAnsiColor", "failureExitCode", "skipCompatibilityCheck", "includePackages", "excludePackages", "sourceMapping", "testMapping", "logConfigLevel", "timeoutInMinutes", "dbmsOutput", "randomTestOrder", "randomTestOrderSeed", "tags"})
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) {
super(connectString);
this.suitePaths = suitePaths;
this.reporters = reporters;
Expand All @@ -39,12 +40,17 @@ public RunCommandConfig(String connectString, String[] suitePaths, ReporterConfi
this.dbmsOutput = dbmsOutput;
this.randomTestOrder = randomTestOrder;
this.randomTestOrderSeed = randomTestOrderSeed;
this.tags = tags;
}

public String[] getSuitePaths() {
return suitePaths;
}

public String[] getTags() {
return tags;
}

public ReporterConfig[] getReporters() {
return reporters;
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/utplsql/cli/PicocliRunCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void runCommandAllArguments() throws Exception {
RunCommandConfig config = parseForConfig("run",
TestHelper.getConnectionString(),
"-p=app.betwnstr,app.basic",
"--tags=tag1,tag.2",
"-d",
"-c",
"-q",
Expand Down Expand Up @@ -51,6 +52,7 @@ void runCommandAllArguments() throws Exception {

assertNotNull(config.getConnectString());
assertThat( config.getSuitePaths(), is(new String[]{"app.betwnstr", "app.basic"}));
assertThat( config.getTags(), is(new String[]{"tag1", "tag.2"}));
assertTrue( config.isOutputAnsiColor() );
assertEquals( LoggerConfiguration.ConfigLevel.NONE, config.getLogConfigLevel());
assertEquals( 10, config.getFailureExitCode());
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/org/utplsql/cli/RunCommandArgumentsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public void allArgumentsAreRecognized() {
"-f=ut_sonar_test_reporter",
"-o=sonar_result.xml",
"-s",
"--tags=tag1,tag2",
"-d",
"-c",
"--failure-exit-code=10",
Expand Down Expand Up @@ -53,4 +54,14 @@ void multiplePaths() {
assertThat( testRunner.getOptions().pathList, contains("app.test_betwnstr", "app.test_award_bonus") );

}

@Test
void provideTags() {
IRunCommand runCmd = TestHelper.createRunCommand(TestHelper.getConnectionString(),
"--tags=tag1,tag.2"
);

TestRunner testRunner = runCmd.newTestRunner(new ArrayList<>());
assertThat( testRunner.getOptions().tags, contains("tag1", "tag.2") );
}
}