1010import org .junit .runners .MethodSorters ;
1111import org .junit .BeforeClass ;
1212import org .junit .AfterClass ;
13+ import org .junit .Rule ;
1314import org .junit .Test ;
15+ import org .junit .rules .TestRule ;
16+ import org .junit .rules .TestWatcher ;
17+ import org .junit .runner .Description ;
1418import java .nio .file .Files ;
1519import java .nio .file .Path ;
1620import java .nio .file .Paths ;
@@ -43,6 +47,22 @@ public static void staticUnprepare() throws Exception {
4347 cleanup ();
4448 }
4549
50+
51+ @ Rule
52+ public TestWatcher watcher = new TestWatcher () {
53+ @ Override
54+ protected void failed (Throwable e , Description description ) {
55+ if (e != null ) {
56+ logger .info ("Method " + description .getMethodName () + " Exception: " + e .getLocalizedMessage ());
57+ }
58+ try {
59+ saveLogFiles (description .getMethodName ());
60+ } catch (Exception le ) {
61+ logger .info ("Unable to save log files : " + le .getLocalizedMessage ());
62+ }
63+ }
64+ };
65+
4666 /**
4767 * test createDomain.sh with only -oracle_home argument
4868 * @throws Exception - if any error occurs
@@ -362,6 +382,7 @@ public void testFDiscoverDomainWithRequiredArgument() throws Exception {
362382
363383 logger .info ("executing command: " + cmd );
364384 ExecResult result = ExecCommand .exec (cmd );
385+
365386 verifyResult (result , "discoverDomain.sh completed successfully" );
366387
367388 // unzip discoveredArchive.zip
@@ -393,6 +414,7 @@ public void testGDiscoverDomainWithModelFile() throws Exception {
393414
394415 logger .info ("executing command: " + cmd );
395416 ExecResult result = ExecCommand .exec (cmd );
417+
396418 verifyResult (result , "discoverDomain.sh completed successfully" );
397419
398420 // verify model file
@@ -418,6 +440,7 @@ public void testHDiscoverDomainJRFDomainType() throws Exception {
418440
419441 logger .info ("executing command: " + cmd );
420442 ExecResult result = ExecCommand .exec (cmd );
443+
421444 verifyResult (result , "discoverDomain.sh completed successfully" );
422445
423446 // verify model file
0 commit comments