77import org .slf4j .LoggerFactory ;
88import org .utplsql .api .*;
99import org .utplsql .api .compatibility .CompatibilityProxy ;
10+ import org .utplsql .api .compatibility .OptionalFeatures ;
1011import org .utplsql .api .db .DefaultDatabaseInformation ;
1112import org .utplsql .api .exception .DatabaseNotCompatibleException ;
1213import org .utplsql .api .exception .OracleCreateStatmenetStuckException ;
@@ -126,6 +127,18 @@ public class RunCommand implements ICommand {
126127 )
127128 private boolean enableDbmsOutput = false ;
128129
130+ @ Parameter (
131+ names = {"-random" , "--random-test-order" },
132+ description = "Enables random order of test executions (default: DISABLED)"
133+ )
134+ private boolean randomTestOrder = false ;
135+
136+ @ Parameter (
137+ names = {"-seed" , "--random-test-order-seed" },
138+ description = "Sets the seed to use for random test execution order. If set, it sets -random to true"
139+ )
140+ private Integer randomTestOrderSeed ;
141+
129142 private CompatibilityProxy compatibilityProxy ;
130143 private ReporterFactory reporterFactory ;
131144 private ReporterManager reporterManager ;
@@ -162,11 +175,7 @@ public int doRun() throws OracleCreateStatmenetStuckException {
162175 initDatabase (dataSource );
163176 reporterList = initReporters (dataSource );
164177
165- // Output a message if --failureExitCode is set but database framework is not capable of
166- String msg = RunCommandChecker .getCheckFailOnErrorMessage (failureExitCode , compatibilityProxy .getUtPlsqlVersion ());
167- if (msg != null ) {
168- System .out .println (msg );
169- }
178+ checkForCompatibility (compatibilityProxy .getUtPlsqlVersion ());
170179
171180 ExecutorService executorService = Executors .newFixedThreadPool (1 + reporterList .size ());
172181
@@ -228,7 +237,28 @@ public int run() {
228237 return Cli .DEFAULT_ERROR_CODE ;
229238 }
230239
231- private TestRunner newTestRunner ( List <Reporter > reporterList ) {
240+ private void checkForCompatibility ( Version utPlSqlVersion ) {
241+ if (!OptionalFeatures .FAIL_ON_ERROR .isAvailableFor (utPlSqlVersion ) && failureExitCode != 1 ) {
242+ System .out .println ("You specified option `--failure-exit-code` but your database framework version (" +
243+ utPlSqlVersion .getNormalizedString () + ") is not able to " +
244+ "redirect failureCodes. Please upgrade to a newer version if you want to use that feature." );
245+ }
246+
247+ if ( !OptionalFeatures .RANDOM_EXECUTION_ORDER .isAvailableFor (utPlSqlVersion ) && randomTestOrder ) {
248+ System .out .println ("You specified option `-random` but your database framework version (" +
249+ utPlSqlVersion .getNormalizedString () + ") is not able to " +
250+ "redirect failureCodes. Please upgrade to a newer version if you want to use that feature." );
251+ }
252+
253+ if ( !OptionalFeatures .RANDOM_EXECUTION_ORDER .isAvailableFor (utPlSqlVersion ) && randomTestOrderSeed != null ) {
254+ System .out .println ("You specified option `-seed` but your database framework version (" +
255+ utPlSqlVersion .getNormalizedString () + ") is not able to " +
256+ "redirect failureCodes. Please upgrade to a newer version if you want to use that feature." );
257+ }
258+
259+ }
260+
261+ TestRunner newTestRunner ( List <Reporter > reporterList ) {
232262
233263 final File baseDir = new File ("" ).getAbsoluteFile ();
234264
@@ -241,7 +271,9 @@ private TestRunner newTestRunner( List<Reporter> reporterList) {
241271 .failOnErrors (true )
242272 .skipCompatibilityCheck (skipCompatibilityCheck )
243273 .includeObjects (getObjectList (includeObjects ))
244- .excludeObjects (getObjectList (excludeObjects ));
274+ .excludeObjects (getObjectList (excludeObjects ))
275+ .randomTestOrder (randomTestOrder )
276+ .randomTestOrderSeed (randomTestOrderSeed );
245277 }
246278
247279 private ArrayList <String > getObjectList (String includeObjects ) {
0 commit comments