Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
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
Next Next commit
Added include and exclude params for coverage reports (issue #6)
  • Loading branch information
Eduard Vlasov committed Dec 21, 2017
commit e8293c4344abe9f12892817ec4253a46db5569b7
48 changes: 45 additions & 3 deletions src/main/java/org/utplsql/cli/RunCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -83,6 +84,21 @@ public class RunCommand {
"most actual. Use this if you use CLI with a development version of utPLSQL-framework")
private boolean skipCompatibilityCheck = false;

@Parameter(
names = {"-include"},
description = "Comma-separated object list to include in the coverage report. " +
"Format: [schema.]package[,[schema.]package ...]. See coverage reporting options in framework documentation"
)
private String includeObjects = null;

@Parameter(
names = {"-exclude"},
description = "Comma-separated object list to exclude from the coverage report. " +
"Format: [schema.]package[,[schema.]package ...]. See coverage reporting options in framework documentation"
)
private String excludeObjects = null;


private CompatibilityProxy compatibilityProxy;

public ConnectionInfo getConnectionInfo() {
Expand Down Expand Up @@ -112,6 +128,24 @@ public int run() throws Exception {
sourceMappingOptions[0] = getFileMapperOptionsByParamListItem(this.sourcePathParams, baseDir);
testMappingOptions[0] = getFileMapperOptionsByParamListItem(this.testPathParams, baseDir);

ArrayList<String> includeObjectsList;
ArrayList<String> excludeObjectsList;

if (includeObjects != null && !includeObjects.isEmpty()) {
includeObjectsList = new ArrayList<>(Arrays.asList(includeObjects.split(",")));
} else {
includeObjectsList = new ArrayList<>();
}

if (excludeObjects != null && !excludeObjects.isEmpty()) {
excludeObjectsList = new ArrayList<>(Arrays.asList(excludeObjects.split(",")));
} else {
excludeObjectsList = new ArrayList<>();
}

final ArrayList<String> finalIncludeObjectsList = includeObjectsList;
final ArrayList<String> finalExcludeObjectsList = excludeObjectsList;

// Do the reporters initialization, so we can use the id to run and gather results.
try (Connection conn = ci.getConnection()) {

Expand Down Expand Up @@ -143,15 +177,23 @@ public int run() throws Exception {
// Run tests.
executorService.submit(() -> {
try (Connection conn = ci.getConnection()) {
new TestRunner()
TestRunner testRunner = new TestRunner()
.addPathList(testPaths)
.addReporterList(reporterList)
.sourceMappingOptions(sourceMappingOptions[0])
.testMappingOptions(testMappingOptions[0])
.colorConsole(this.colorConsole)
.failOnErrors(true)
.skipCompatibilityCheck(skipCompatibilityCheck)
.run(conn);
.skipCompatibilityCheck(skipCompatibilityCheck);

for (String includeObject: finalIncludeObjectsList){
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done in Fluent interface manner to stay within the same pattern. Will need a change in Java API. I will try to do this soon.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your efforts, though! Very appreciated!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean create a function like "includeObjects" or something like that? I also can do that, in general, if you are busy now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, creating a function in the TestRunner class, return the TestRunner instance so we can continue to use fluent interface pattern. The need to create a loop outside just to add objects feels uncomfortable to me :)

testRunner.includeObject(includeObject);
}
for (String excludeObject: finalExcludeObjectsList){
testRunner.excludeObject(excludeObject);
}

testRunner.run(conn);
} catch (SomeTestsFailedException e) {
returnCode[0] = this.failureExitCode;
} catch (SQLException e) {
Expand Down