22
33import static org .testng .Assert .assertEquals ;
44import static org .testng .Assert .assertFalse ;
5+ import static org .testng .Assert .assertNotNull ;
56import static org .testng .Assert .assertNull ;
67import static org .testng .Assert .assertTrue ;
78
@@ -28,7 +29,8 @@ public void verifyHappyPath() {
2829 assertEquals (rla .getIgnoredTests ().size (), 0 , "Incorrect ignored test count" );
2930
3031 Description description = rla .getPassedTests ().get (0 );
31- UnitTestCapture watcher = ArtifactCollector .getWatcher (description , UnitTestCapture .class ).get ();
32+ UnitTestCapture watcher = rla .getWatcher (description );
33+ assertNotNull (watcher , "Unit test watcher not registered" );
3234 assertNull (watcher .getArtifactProvider ().getCaptureState (), "Artifact provider capture state should be 'null'" );
3335 assertNull (watcher .getArtifactPath (), "Artifact capture should not have been requested" );
3436 }
@@ -47,7 +49,8 @@ public void verifyCaptureOnFailure() {
4749 assertEquals (rla .getIgnoredTests ().size (), 0 , "Incorrect ignored test count" );
4850
4951 Description description = rla .getFailedTests ().get (0 );
50- UnitTestCapture watcher = ArtifactCollector .getWatcher (description , UnitTestCapture .class ).get ();
52+ UnitTestCapture watcher = rla .getWatcher (description );
53+ assertNotNull (watcher , "Unit test watcher not registered" );
5154 assertEquals (watcher .getArtifactProvider ().getCaptureState (), CaptureState .CAPTURE_SUCCESS , "Incorrect artifact provider capture state" );
5255 assertTrue (watcher .getArtifactPath ().isPresent (), "Artifact capture output path is not present" );
5356 }
@@ -66,7 +69,8 @@ public void verifyCanNotCapture() {
6669 assertEquals (rla .getIgnoredTests ().size (), 0 , "Incorrect ignored test count" );
6770
6871 Description description = rla .getFailedTests ().get (0 );
69- UnitTestCapture watcher = ArtifactCollector .getWatcher (description , UnitTestCapture .class ).get ();
72+ UnitTestCapture watcher = rla .getWatcher (description );
73+ assertNotNull (watcher , "Unit test watcher not registered" );
7074 assertEquals (watcher .getArtifactProvider ().getCaptureState (), CaptureState .CAN_NOT_CAPTURE , "Incorrect artifact provider capture state" );
7175 assertFalse (watcher .getArtifactPath ().isPresent (), "Artifact capture output path should not be present" );
7276 }
@@ -85,7 +89,8 @@ public void verifyWillNotCapture() {
8589 assertEquals (rla .getIgnoredTests ().size (), 0 , "Incorrect ignored test count" );
8690
8791 Description description = rla .getFailedTests ().get (0 );
88- UnitTestCapture watcher = ArtifactCollector .getWatcher (description , UnitTestCapture .class ).get ();
92+ UnitTestCapture watcher = rla .getWatcher (description );
93+ assertNotNull (watcher , "Unit test watcher not registered" );
8994 assertEquals (watcher .getArtifactProvider ().getCaptureState (), CaptureState .CAPTURE_FAILED , "Incorrect artifact provider capture state" );
9095 assertFalse (watcher .getArtifactPath ().isPresent (), "Artifact capture output path should not be present" );
9196 }
@@ -104,7 +109,8 @@ public void verifyOnDemandCapture() {
104109 assertEquals (rla .getIgnoredTests ().size (), 0 , "Incorrect ignored test count" );
105110
106111 Description description = rla .getPassedTests ().get (0 );
107- UnitTestCapture watcher = ArtifactCollector .getWatcher (description , UnitTestCapture .class ).get ();
112+ UnitTestCapture watcher = rla .getWatcher (description );
113+ assertNotNull (watcher , "Unit test watcher not registered" );
108114 assertEquals (watcher .getArtifactProvider ().getCaptureState (), CaptureState .CAPTURE_SUCCESS , "Incorrect artifact provider capture state" );
109115 assertTrue (watcher .getArtifactPath ().isPresent (), "Artifact capture output path is not present" );
110116 }
@@ -123,7 +129,8 @@ public void verifyParameterizedCapture() {
123129 assertEquals (rla .getIgnoredTests ().size (), 0 , "Incorrect ignored test count" );
124130
125131 Description description = rla .getFailedTests ().get (0 );
126- UnitTestCapture watcher = ArtifactCollector .getWatcher (description , UnitTestCapture .class ).get ();
132+ UnitTestCapture watcher = rla .getWatcher (description );
133+ assertNotNull (watcher , "Unit test watcher not registered" );
127134 assertEquals (watcher .getArtifactProvider ().getCaptureState (), CaptureState .CAPTURE_SUCCESS , "Incorrect artifact provider capture state" );
128135 assertTrue (watcher .getArtifactPath ().isPresent (), "Artifact capture output path is not present" );
129136 }
@@ -142,7 +149,8 @@ public void verifyJUnitParamsCapture() {
142149 assertEquals (rla .getIgnoredTests ().size (), 0 , "Incorrect ignored test count" );
143150
144151 Description description = rla .getFailedTests ().get (0 );
145- UnitTestCapture watcher = ArtifactCollector .getWatcher (description , UnitTestCapture .class ).get ();
152+ UnitTestCapture watcher = rla .getWatcher (description );
153+ assertNotNull (watcher , "Unit test watcher not registered" );
146154 assertEquals (watcher .getArtifactProvider ().getCaptureState (), CaptureState .CAPTURE_SUCCESS , "Incorrect artifact provider capture state" );
147155 assertTrue (watcher .getArtifactPath ().isPresent (), "Artifact capture output path is not present" );
148156 }
@@ -163,7 +171,8 @@ public void verifyTheoriesCapture() {
163171 assertEquals (rla .getFailedTheories ().size (), 1 , "Incorrect failed theory count" );
164172
165173 Description description = rla .getFailedTheories ().get (0 );
166- UnitTestCapture watcher = ArtifactCollector .getWatcher (description , UnitTestCapture .class ).get ();
174+ UnitTestCapture watcher = rla .getWatcher (description );
175+ assertNotNull (watcher , "Unit test watcher not registered" );
167176 assertEquals (watcher .getArtifactProvider ().getCaptureState (), CaptureState .CAPTURE_SUCCESS , "Incorrect artifact provider capture state" );
168177 assertTrue (watcher .getArtifactPath ().isPresent (), "Artifact capture output path is not present" );
169178 }
0 commit comments