Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e6625e3 commit 8fb3072Copy full SHA for 8fb3072
10 files changed
src/main/java/org/utplsql/api/TestRunner.java
@@ -118,6 +118,17 @@ public TestRunner setReporterFactory(ReporterFactory reporterFactory) {
118
return this;
119
}
120
121
+ public TestRunner randomTestOrder(boolean randomTestOrder ) {
122
+ this.options.randomTestOrder = randomTestOrder;
123
+ return this;
124
+ }
125
+
126
+ public TestRunner randomTestOrderSeed( Integer seed ) {
127
+ this.options.randomTestOrderSeed = seed;
128
+ if ( seed != null ) this.options.randomTestOrder = true;
129
130
131
132
private void delayedAddReporters() {
133
if (reporterFactory != null) {
134
reporterNames.forEach(this::addReporter);
src/main/java/org/utplsql/api/TestRunnerOptions.java
@@ -25,4 +25,6 @@ public class TestRunnerOptions {
25
public boolean failOnErrors = false;
26
public boolean skipCompatibilityCheck = false;
27
public String clientCharacterSet = Charset.defaultCharset().toString();
28
+ public boolean randomTestOrder = false;
29
+ public Integer randomTestOrderSeed;
30
src/main/java/org/utplsql/api/Version.java
@@ -31,10 +31,11 @@ public class Version implements Comparable<Version> {
31
public final static Version V3_1_4 = new Version("3.1.4", 3, 1, 4, null, true);
32
public final static Version V3_1_5 = new Version("3.1.5", 3, 1, 5, null, true);
33
public final static Version V3_1_6 = new Version("3.1.6", 3, 1, 6, null, true);
34
+ public final static Version V3_1_7 = new Version("3.1.7", 3, 1, 7, null, true);
35
private final static Map<String, Version> knownVersions =
- Stream.of(V3_0_0, V3_0_1, V3_0_2, V3_0_3, V3_0_4, V3_1_0, V3_1_1, V3_1_2, V3_1_3, V3_1_4, V3_1_5, V3_1_6)
36
+ Stream.of(V3_0_0, V3_0_1, V3_0_2, V3_0_3, V3_0_4, V3_1_0, V3_1_1, V3_1_2, V3_1_3, V3_1_4, V3_1_5, V3_1_6, V3_1_7)
37
.collect(toMap(Version::toString, Function.identity()));
- public final static Version LATEST = V3_1_6;
38
+ public final static Version LATEST = V3_1_7;
39
40
private final String origString;
41
private final Integer major;
src/main/java/org/utplsql/api/compatibility/OptionalFeatures.java
@@ -11,7 +11,8 @@ public enum OptionalFeatures {
11
FAIL_ON_ERROR("3.0.3.1266", null),
12
FRAMEWORK_COMPATIBILITY_CHECK("3.0.3.1266", null),
13
CUSTOM_REPORTERS("3.1.0.1849", null),
14
- CLIENT_CHARACTER_SET("3.1.2.2130", null);
+ CLIENT_CHARACTER_SET("3.1.2.2130", null),
15
+ RANDOM_EXECUTION_ORDER("3.1.7.2795", null);
16
17
private final Version minVersion;
18
private final Version maxVersion;
src/main/java/org/utplsql/api/testRunner/ActualTestRunnerStatement.java
@@ -22,6 +22,7 @@ protected String getSql() {
22
// Workaround because Oracle JDBC doesn't support passing boolean to stored procedures.
23
String colorConsoleStr = Boolean.toString(options.colorConsole);
24
String failOnErrors = Boolean.toString(options.failOnErrors);
+ String randomExecutionOrder = Boolean.toString(options.randomTestOrder);
return
"BEGIN " +
@@ -35,7 +36,9 @@ protected String getSql() {
"a_include_objects => ?, " +
"a_exclude_objects => ?, " +
"a_fail_on_errors => " + failOnErrors + ", " +
- "a_client_character_set => ?); " +
+ "a_client_character_set => ?" +
+ //(options.randomTestOrderSeed != null ) ?
+ "); " +
42
"END;";
43
44
src/main/java/org/utplsql/api/testRunner/Pre317TestRunnerStatement.java
@@ -0,0 +1,50 @@
1
+package org.utplsql.api.testRunner;
2
3
+import org.utplsql.api.TestRunnerOptions;
4
5
+import java.sql.Connection;
6
+import java.sql.SQLException;
7
8
+/**
9
+ * Provides the call to run tests for the most actual Framework version.
10
+ * Includes fail on error
+ *
+ * @author pesse
+ */
+class Pre317TestRunnerStatement extends AbstractTestRunnerStatement {
+ public Pre317TestRunnerStatement(TestRunnerOptions options, Connection connection) throws SQLException {
+ super(options, connection);
19
20
+ @Override
21
+ protected String getSql() {
+ // Workaround because Oracle JDBC doesn't support passing boolean to stored procedures.
+ String colorConsoleStr = Boolean.toString(options.colorConsole);
+ String failOnErrors = Boolean.toString(options.failOnErrors);
+ return
+ "BEGIN " +
+ "ut_runner.run(" +
+ "a_paths => ?, " +
+ "a_reporters => ?, " +
+ "a_color_console => " + colorConsoleStr + ", " +
+ "a_coverage_schemes => ?, " +
+ "a_source_file_mappings => ?, " +
+ "a_test_file_mappings => ?, " +
+ "a_include_objects => ?, " +
+ "a_exclude_objects => ?, " +
+ "a_fail_on_errors => " + failOnErrors + ", " +
+ "a_client_character_set => ?); " +
+ "END;";
+ protected int createStatement() throws SQLException {
+ int curParamIdx = super.createStatement();
45
46
+ callableStatement.setString(++curParamIdx, options.clientCharacterSet);
47
48
+ return curParamIdx;
49
50
+}
src/main/java/org/utplsql/api/testRunner/TestRunnerStatementProvider.java
@@ -35,6 +35,8 @@ public static TestRunnerStatement getCompatibleTestRunnerStatement(Version datab
stmt = new Pre303TestRunnerStatement(options, conn);
} else if (databaseVersion.isLessThan(Version.V3_1_2)) {
stmt = new Pre312TestRunnerStatement(options, conn);
+ } else if (databaseVersion.isLessThan(Version.V3_1_7)) {
+ stmt = new Pre317TestRunnerStatement(options, conn);
} catch (InvalidVersionException ignored) {
src/test/java/org/utplsql/api/OptionalFeaturesIT.java
@@ -64,4 +64,15 @@ void clientCharset() throws SQLException, InvalidVersionException {
64
assertFalse(available);
65
66
67
68
+ @Test
69
+ void randomExecutionOrder() throws SQLException, InvalidVersionException {
70
+ boolean available = OptionalFeatures.RANDOM_EXECUTION_ORDER.isAvailableFor(getConnection());
71
72
+ if (getDatabaseVersion().isGreaterOrEqualThan(Version.V3_1_7)) {
73
+ assertTrue(available);
74
+ } else {
75
+ assertFalse(available);
76
77
78
src/test/java/org/utplsql/api/TestRunnerIT.java
@@ -78,4 +78,14 @@ void failOnErrors() throws SQLException, InvalidVersionException {
79
80
81
82
+ void runWithRandomExecutionOrder() throws SQLException {
83
+ CompatibilityProxy proxy = new CompatibilityProxy(getConnection());
84
85
+ new TestRunner()
86
+ .randomTestOrder(true)
87
+ .randomTestOrderSeed(123)
88
+ .run(getConnection());
89
90
91
src/test/java/org/utplsql/api/testRunner/TestRunnerStatementProviderIT.java
@@ -31,8 +31,20 @@ void testGettingPre312Version_from_311() throws SQLException {
@Test
- void testGettingActualVersion() throws SQLException {
+ void testGettingPre317Version_from_312() throws SQLException {
TestRunnerStatement stmt = TestRunnerStatementProvider.getCompatibleTestRunnerStatement(Version.V3_1_2, new TestRunnerOptions(), getConnection());
+ assertEquals(Pre317TestRunnerStatement.class, stmt.getClass());
+ void testGettingPre317Version_from_316() throws SQLException {
+ TestRunnerStatement stmt = TestRunnerStatementProvider.getCompatibleTestRunnerStatement(Version.V3_1_6, new TestRunnerOptions(), getConnection());
+ void testGettingActualVersion_from_latest() throws SQLException {
+ TestRunnerStatement stmt = TestRunnerStatementProvider.getCompatibleTestRunnerStatement(Version.LATEST, new TestRunnerOptions(), getConnection());
assertEquals(ActualTestRunnerStatement.class, stmt.getClass());
0 commit comments