1313 */
1414public class RunCommandTest {
1515
16- private static String sUrl ;
17- private static String sUser ;
18- private static String sPass ;
19-
20- static {
21- sUrl = System .getenv ("DB_URL" ) != null ? System .getenv ("DB_URL" ) : "192.168.99.100:1521:XE" ;
22- sUser = System .getenv ("DB_USER" ) != null ? System .getenv ("DB_USER" ) : "app" ;
23- sPass = System .getenv ("DB_PASS" ) != null ? System .getenv ("DB_PASS" ) : "app" ;
24- }
25-
26- private RunCommand createRunCommand (String ... args ) {
27- RunCommand runCmd = new RunCommand ();
28-
29- JCommander .newBuilder ()
30- .addObject (runCmd )
31- .args (args )
32- .build ();
33-
34- return runCmd ;
35- }
36-
37- private String getConnectionString () {
38- return sUser + "/" + sPass + "@" + sUrl ;
39- }
40-
4116 @ Test
4217 public void reporterOptions_Default () {
43- RunCommand runCmd = createRunCommand (getConnectionString ());
18+ RunCommand runCmd = RunCommandTestHelper . createRunCommand (RunCommandTestHelper . getConnectionString ());
4419
4520 List <ReporterOptions > reporterOptionsList = runCmd .getReporterOptionsList ();
4621
@@ -53,7 +28,7 @@ public void reporterOptions_Default() {
5328
5429 @ Test
5530 public void reporterOptions_OneReporter () {
56- RunCommand runCmd = createRunCommand (getConnectionString (), "-f=ut_documentation_reporter" , "-o=output.txt" );
31+ RunCommand runCmd = RunCommandTestHelper . createRunCommand (RunCommandTestHelper . getConnectionString (), "-f=ut_documentation_reporter" , "-o=output.txt" );
5732
5833 List <ReporterOptions > reporterOptionsList = runCmd .getReporterOptionsList ();
5934
@@ -66,7 +41,7 @@ public void reporterOptions_OneReporter() {
6641
6742 @ Test
6843 public void reporterOptions_OneReporterForceScreen () {
69- RunCommand runCmd = createRunCommand (getConnectionString (), "-f=ut_documentation_reporter" , "-o=output.txt" , "-s" );
44+ RunCommand runCmd = RunCommandTestHelper . createRunCommand (RunCommandTestHelper . getConnectionString (), "-f=ut_documentation_reporter" , "-o=output.txt" , "-s" );
7045
7146 List <ReporterOptions > reporterOptionsList = runCmd .getReporterOptionsList ();
7247
@@ -79,7 +54,7 @@ public void reporterOptions_OneReporterForceScreen() {
7954
8055 @ Test
8156 public void reporterOptions_OneReporterForceScreenInverse () {
82- RunCommand runCmd = createRunCommand (getConnectionString (), "-f=ut_documentation_reporter" , "-s" , "-o=output.txt" );
57+ RunCommand runCmd = RunCommandTestHelper . createRunCommand (RunCommandTestHelper . getConnectionString (), "-f=ut_documentation_reporter" , "-s" , "-o=output.txt" );
8358
8459 List <ReporterOptions > reporterOptionsList = runCmd .getReporterOptionsList ();
8560
@@ -92,7 +67,7 @@ public void reporterOptions_OneReporterForceScreenInverse() {
9267
9368 @ Test
9469 public void reporterOptions_TwoReporters () {
95- RunCommand runCmd = createRunCommand (getConnectionString (),
70+ RunCommand runCmd = RunCommandTestHelper . createRunCommand (RunCommandTestHelper . getConnectionString (),
9671 "-f=ut_documentation_reporter" ,
9772 "-f=ut_coverage_html_reporter" , "-o=coverage.html" , "-s" );
9873
@@ -111,25 +86,4 @@ public void reporterOptions_TwoReporters() {
11186 Assert .assertTrue (reporterOptions2 .outputToScreen ());
11287 }
11388
114- @ Test
115- public void run_Default () {
116- RunCommand runCmd = createRunCommand (getConnectionString (),
117- "-f=ut_documentation_reporter" ,
118- "-c" ,
119- "--failure-exit-code=2" );
120-
121- try {
122- int result = runCmd .run ();
123-
124- // Only expect failure-exit-code to work on several framework versions
125- if (OptionalFeatures .FAIL_ON_ERROR .isAvailableFor (runCmd .getDatabaseVersion ()) )
126- Assert .assertEquals (2 , result );
127- else
128- Assert .assertEquals (0 , result );
129- }
130- catch ( Exception e ) {
131- Assert .fail (e .getMessage ());
132- }
133- }
134-
13589}
0 commit comments