2222 *
2323 * @author pesse
2424 */
25- public class RunCommandCoverageReporterIT {
25+ public class RunCommandCoverageReporterIT extends AbstractFileOutputTest {
2626
2727 private static final Pattern REGEX_COVERAGE_TITLE = Pattern .compile ("<a href=\" [a-zA-Z0-9#]+\" class=\" src_link\" title=\" [a-zA-Z\\ ._]+\" >([a-zA-Z0-9\\ ._]+)<\\ /a>" );
2828
29- private Set <Path > tempPaths ;
30-
31- private void addTempPath (Path path ) {
32- tempPaths .add (path );
33- }
3429
3530 private String getTempCoverageFileName (int counter ) {
3631
@@ -47,7 +42,7 @@ private Path getTempCoverageFilePath() {
4742 int i = 1 ;
4843 Path p = Paths .get (getTempCoverageFileName (i ));
4944
50- while ((Files .exists (p ) || tempPaths . contains (p )) && i < 100 )
45+ while ((Files .exists (p ) || tempPathExists (p )) && i < 100 )
5146 p = Paths .get (getTempCoverageFileName (i ++));
5247
5348 if (i >= 100 )
@@ -77,11 +72,6 @@ private boolean hasCoverageListed(String content, String packageName) {
7772 return false ;
7873 }
7974
80- @ BeforeEach
81- public void setupTest () {
82- tempPaths = new HashSet <>();
83- }
84-
8575 @ Test
8676 public void run_CodeCoverageWithIncludeAndExclude () throws Exception {
8777
@@ -121,27 +111,11 @@ public void coverageReporterWriteAssetsToOutput() throws Exception {
121111 assertTrue (applicationJs .exists ());
122112
123113 // Check correct script-part in HTML source exists
124- String content = new Scanner ( coveragePath ). useDelimiter ( " \\ Z" ). next ( );
114+ String content = new String ( Files . readAllBytes ( coveragePath ) );
125115 assertTrue (content .contains ("<script src='" + coverageAssetsPath .toString () + "/application.js' type='text/javascript'>" ));
126116
127117 // Check correct title exists
128118 assertTrue (content .contains ("<title>Code coverage</title>" ));
129119 }
130120
131- @ AfterEach
132- public void deleteTempFiles () {
133- tempPaths .forEach (p -> deleteDir (p .toFile ()));
134- }
135-
136- void deleteDir (File file ) {
137- if (file .exists ()) {
138- File [] contents = file .listFiles ();
139- if (contents != null ) {
140- for (File f : contents ) {
141- deleteDir (f );
142- }
143- }
144- file .delete ();
145- }
146- }
147121}
0 commit comments