1 package org.apache.maven.surefire.report;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import org.apache.maven.plugin.surefire.report.ConsoleOutputFileReporter;
24
25 import junit.framework.TestCase;
26
27 public class ConsoleOutputFileReporterTest
28 extends TestCase
29 {
30
31 private ConsoleOutputFileReporter reporter;
32
33 private ReportEntry reportEntry;
34
35 private static final String testName = "org.apache.maven.surefire.report.ConsoleOutputFileReporterTest";
36
37
38
39
40 public void testFileNameWithoutSuffix()
41 {
42 File reportDir = new File( System.getProperty( "java.io.tmpdir" ) );
43 reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
44 reporter = new ConsoleOutputFileReporter( reportDir, null );
45 reporter.testSetStarting( reportEntry );
46 reporter.writeTestOutput( "some text".getBytes(), 0, 5, true );
47 reporter.testSetCompleted( reportEntry );
48
49 File expectedReportFile = new File( reportDir, testName + "-output.txt" );
50 assertTrue( "Report file (" + expectedReportFile.getAbsolutePath() + ") doesn't exist",
51 expectedReportFile.exists() );
52 expectedReportFile.delete();
53 }
54
55
56
57
58 public void testFileNameWithSuffix()
59 {
60 File reportDir = new File( System.getProperty( "java.io.tmpdir" ) );
61 String suffixText = "sampleSuffixText";
62 reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
63 reporter = new ConsoleOutputFileReporter( reportDir, suffixText );
64 reporter.testSetStarting( reportEntry );
65 reporter.writeTestOutput( "some text".getBytes(), 0, 5, true );
66 reporter.testSetCompleted( reportEntry );
67
68 File expectedReportFile = new File( reportDir, testName + "-" + suffixText + "-output.txt" );
69 assertTrue( "Report file (" + expectedReportFile.getAbsolutePath() + ") doesn't exist",
70 expectedReportFile.exists() );
71 expectedReportFile.delete();
72 }
73
74 }