From 8501d6a8206addcdff8f2a2457382309be23579c Mon Sep 17 00:00:00 2001 From: pesse Date: Thu, 4 Apr 2019 21:53:07 +0200 Subject: [PATCH 1/4] Update version --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ba8928f..b1fc034 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.utplsql cli - 3.1.6 + 3.1.7-SNAPSHOT jar cli @@ -22,7 +22,7 @@ org.utplsql java-api - 3.1.6 + 3.1.7-SNAPSHOT compile From 4317e4ec7344fd7fb5cefd2d99d6adbd0b7972ec Mon Sep 17 00:00:00 2001 From: pesse Date: Thu, 4 Apr 2019 21:54:01 +0200 Subject: [PATCH 2/4] Enable DBMS-Output and use some new Compatibility-Proxy functions Fixes #136 Fixes #137 --- src/main/java/org/utplsql/cli/RunCommand.java | 12 +++++++++--- src/main/java/org/utplsql/cli/RunTestRunnerTask.java | 7 ++++++- src/test/java/org/utplsql/cli/RunCommandIT.java | 10 ++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/utplsql/cli/RunCommand.java b/src/main/java/org/utplsql/cli/RunCommand.java index 65ae15c..e85b9e7 100644 --- a/src/main/java/org/utplsql/cli/RunCommand.java +++ b/src/main/java/org/utplsql/cli/RunCommand.java @@ -120,6 +120,12 @@ public class RunCommand implements ICommand { description = "Sets the timeout in minutes after which the cli will abort. Default 60") private int timeoutInMinutes = 60; + @Parameter( + names = {"-dbout", "--dbms_output"}, + description = "Enables DBMS_OUTPUT for the TestRunner (default: DISABLED)" + ) + private boolean enableDbmsOutput = false; + private CompatibilityProxy compatibilityProxy; private ReporterFactory reporterFactory; private ReporterManager reporterManager; @@ -157,7 +163,7 @@ public int doRun() throws OracleCreateStatmenetStuckException { reporterList = initReporters(dataSource); // Output a message if --failureExitCode is set but database framework is not capable of - String msg = RunCommandChecker.getCheckFailOnErrorMessage(failureExitCode, compatibilityProxy.getDatabaseVersion()); + String msg = RunCommandChecker.getCheckFailOnErrorMessage(failureExitCode, compatibilityProxy.getUtPlsqlVersion()); if (msg != null) { System.out.println(msg); } @@ -165,7 +171,7 @@ public int doRun() throws OracleCreateStatmenetStuckException { ExecutorService executorService = Executors.newFixedThreadPool(1 + reporterList.size()); // Run tests. - Future future = executorService.submit(new RunTestRunnerTask(dataSource, newTestRunner(reporterList))); + Future future = executorService.submit(new RunTestRunnerTask(dataSource, newTestRunner(reporterList), enableDbmsOutput)); // Gather each reporter results on a separate thread. getReporterManager().startReporterGatherers(executorService, dataSource); @@ -278,7 +284,7 @@ private void initDatabase(DataSource dataSource) throws SQLException { // First of all do a compatibility check and fail-fast compatibilityProxy = checkFrameworkCompatibility(conn); - logger.info("Successfully connected to database. UtPLSQL core: {}", compatibilityProxy.getDatabaseVersion()); + logger.info("Successfully connected to database. UtPLSQL core: {}", compatibilityProxy.getVersionDescription()); logger.info("Oracle-Version: {}", new DefaultDatabaseInformation().getOracleVersion(conn)); } catch (SQLException e) { diff --git a/src/main/java/org/utplsql/cli/RunTestRunnerTask.java b/src/main/java/org/utplsql/cli/RunTestRunnerTask.java index 99c388f..4a293c4 100644 --- a/src/main/java/org/utplsql/cli/RunTestRunnerTask.java +++ b/src/main/java/org/utplsql/cli/RunTestRunnerTask.java @@ -2,6 +2,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.utplsql.api.DBHelper; import org.utplsql.api.TestRunner; import org.utplsql.api.exception.OracleCreateStatmenetStuckException; import org.utplsql.api.exception.SomeTestsFailedException; @@ -24,10 +25,12 @@ public class RunTestRunnerTask implements Callable { private static final Logger logger = LoggerFactory.getLogger(RunTestRunnerTask.class); private DataSource dataSource; private TestRunner testRunner; + private boolean enableDmbsOutput; - RunTestRunnerTask(DataSource dataSource, TestRunner testRunner) { + RunTestRunnerTask(DataSource dataSource, TestRunner testRunner, boolean enableDmbsOutput) { this.dataSource = dataSource; this.testRunner = testRunner; + this.enableDmbsOutput = enableDmbsOutput; } @Override @@ -35,6 +38,7 @@ public Boolean call() throws Exception { Connection conn = null; try { conn = dataSource.getConnection(); + if ( enableDmbsOutput ) DBHelper.enableDBMSOutput(conn); logger.info("Running tests now."); logger.info("--------------------------------------"); testRunner.run(conn); @@ -54,6 +58,7 @@ public Boolean call() throws Exception { } finally { if ( conn != null ) { try { + if ( enableDmbsOutput ) DBHelper.disableDBMSOutput(conn); conn.close(); } catch (SQLException e) { logger.error(e.getMessage(), e); diff --git a/src/test/java/org/utplsql/cli/RunCommandIT.java b/src/test/java/org/utplsql/cli/RunCommandIT.java index ae14b5a..7f1185e 100644 --- a/src/test/java/org/utplsql/cli/RunCommandIT.java +++ b/src/test/java/org/utplsql/cli/RunCommandIT.java @@ -65,4 +65,14 @@ void run_MultipleReporters() throws Exception { } + @Test + void run_withDbmsOutputEnabled() throws Exception { + + int result = TestHelper.runApp("run", + TestHelper.getConnectionString(), + "-dbout", + "--failure-exit-code=2"); + + assertValidReturnCode(result); + } } From da5ee925b2b119082358547bd7fab18b3731e4d4 Mon Sep 17 00:00:00 2001 From: pesse Date: Thu, 4 Apr 2019 22:08:37 +0200 Subject: [PATCH 3/4] Update Readme: Add new parameters Also add aliases to existing parameters --- README.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4da10f0..e7e78de 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ utplsql run "my/Username"/"myP@ssword"@connectstring #### Options ``` -p=suite_path(s) - A suite path or a comma separated list of suite paths for unit test to be executed. - The path(s) can be in one of the following formats: +(--path) The path(s) can be in one of the following formats: schema[.package[.procedure]] schema:suite[.suite[.suite][...]][.procedure] Both formats can be mixed in the list. @@ -94,7 +94,7 @@ utplsql run "my/Username"/"myP@ssword"@connectstring If -p is omitted, the current schema is used. -f=format - A reporter to be used for reporting. - If no -f option is provided, the default ut_documentation_reporter is used. +(--format) If no -f option is provided, the default ut_documentation_reporter is used. See reporters command for possible values -o=output - Defines file name to save the output from the specified reporter. If defined, the output is not displayed on screen by default. This can be changed with the -s parameter. @@ -119,12 +119,14 @@ utplsql run "my/Username"/"myP@ssword"@connectstring -name_subexpression=subexpression_number -c - If specified, enables printing of test results in colors as defined by ANSICONSOLE standards. - Works only on reporeters that support colors (ut_documentation_reporter). +(--color) Works only on reporeters that support colors (ut_documentation_reporter). ---failure-exit-code - Override the exit code on failure, defaults to 1. You can set it to 0 to always exit with a success status. +-fcode=code - Override the exit code on failure, defaults to 1. You can set it to 0 to always exit with a success status. +(--failure-exit-code) -scc - If specified, skips the compatibility-check with the version of the database framework. - If you skip compatibility-check, CLI will expect the most actual framework version +(--skip- If you skip compatibility-check, CLI will expect the most actual framework version + compatibility-check) -include=pckg_list - Comma-separated object list to include in the coverage report. Format: [schema.]package[,[schema.]package ...]. @@ -135,13 +137,16 @@ utplsql run "my/Username"/"myP@ssword"@connectstring See coverage reporting options in framework documentation. -q - Does not output the informational messages normally printed to console. - Default: false +(--quiet) Default: false -d - Outputs a load of debug information to console - Default: false +(--debug) Default: false --t - Sets the timeout in minutes after which the cli will abort. - Default 60 +-t=timeInMinutes - Sets the timeout in minutes after which the cli will abort. +(--timeout) Default 60 + +-dbout - Enables DBMS_OUTPUT in the TestRunner-Session +(--dbms_output) Default: false ``` Parameters -f, -o, -s are correlated. That is parameters -o and -s are controlling outputs for reporter specified by the preceding -f parameter. From c24682876c948a68d18c577ea7a2f6dd52199ede Mon Sep 17 00:00:00 2001 From: pesse Date: Thu, 4 Apr 2019 22:10:38 +0200 Subject: [PATCH 4/4] Update Readme: Most actual Reporters --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index e7e78de..d8391e3 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,9 @@ UT_COVERALLS_REPORTER: Designed for [Coveralls](https://coveralls.io/). JSON format conforms with specification: https://docs.coveralls.io/api-introduction +UT_DEBUG_REPORTER: + No description available + UT_DOCUMENTATION_REPORTER: A textual pretty-print of unit test results (usually use for console output) Provides additional properties lvl and failed @@ -226,6 +229,9 @@ UT_DOCUMENTATION_REPORTER: UT_JUNIT_REPORTER: Provides outcomes in a format conforming with JUnit 4 and above as defined in: https://gist.github.com/kuzuha/232902acab1344d6b578 +UT_REALTIME_REPORTER: + Provides test results in a XML format, for clients such as SQL Developer interested in showing progressing details. + UT_SONAR_TEST_REPORTER: Generates a JSON report providing detailed information on test execution. Designed for [SonarQube](https://about.sonarqube.com/) to report test execution.