13
13
import org .junit .jupiter .params .ParameterizedTest ;
14
14
import org .junit .jupiter .params .provider .MethodSource ;
15
15
16
- import java .io .File ;
17
- import java .io .FileOutputStream ;
18
16
import java .io .IOException ;
19
17
import java .io .InputStream ;
20
18
import java .nio .file .Files ;
21
19
import java .nio .file .Path ;
20
+ import java .nio .file .Paths ;
22
21
import java .util .ArrayList ;
23
22
import java .util .Comparator ;
24
23
import java .util .LinkedHashMap ;
25
24
import java .util .List ;
26
25
import java .util .Map ;
27
26
import java .util .stream .Collectors ;
28
27
28
+ import static java .nio .file .Files .newOutputStream ;
29
29
import static org .hamcrest .CoreMatchers .is ;
30
30
import static org .hamcrest .MatcherAssert .assertThat ;
31
31
import static org .hamcrest .collection .IsIterableContainingInRelativeOrder .containsInRelativeOrder ;
@@ -36,11 +36,10 @@ public class CompatibilityTest {
36
36
@ ParameterizedTest
37
37
@ MethodSource ("io.cucumber.compatibility.TestCase#testCases" )
38
38
void produces_expected_output_for (TestCase testCase ) throws IOException {
39
- File parentDir = new File ("target/messages/" + testCase .getId ());
40
- parentDir .mkdirs ();
41
- File outputNdjson = new File (parentDir , "out.ndjson" );
42
- File outputHtml = new File (parentDir , "out.html" );
43
- File outputJson = new File (parentDir , "out.json" );
39
+ Path parentDir = Files .createDirectories (Paths .get ("target" , "messages" , testCase .getId ()));
40
+ Path outputNdjson = parentDir .resolve ("out.ndjson" );
41
+ Path outputHtml = parentDir .resolve ("out.html" );
42
+ Path outputJson = parentDir .resolve ("out.json" );
44
43
45
44
try {
46
45
Runtime .builder ()
@@ -49,17 +48,17 @@ void produces_expected_output_for(TestCase testCase) throws IOException {
49
48
.addFeature (testCase .getFeature ())
50
49
.build ())
51
50
.withAdditionalPlugins (
52
- new MessageFormatter (new FileOutputStream (outputNdjson )),
53
- new HtmlFormatter (new FileOutputStream (outputHtml )),
54
- new JsonFormatter (new FileOutputStream (outputJson )))
51
+ new MessageFormatter (newOutputStream (outputNdjson )),
52
+ new HtmlFormatter (newOutputStream (outputHtml )),
53
+ new JsonFormatter (newOutputStream (outputJson )))
55
54
.build ()
56
55
.run ();
57
56
} catch (Exception ignored ) {
58
57
59
58
}
60
59
61
60
List <Messages .Envelope > expected = readAllMessages (testCase .getExpectedFile ());
62
- List <Messages .Envelope > actual = readAllMessages (outputNdjson . toPath () );
61
+ List <Messages .Envelope > actual = readAllMessages (outputNdjson );
63
62
64
63
Map <String , List <GeneratedMessageV3 >> expectedEnvelopes = openEnvelopes (expected );
65
64
Map <String , List <GeneratedMessageV3 >> actualEnvelopes = openEnvelopes (actual );
0 commit comments