1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.jameleon.reporting;
20
21 import net.sf.jameleon.TestCaseTag;
22 import net.sf.jameleon.exception.JameleonException;
23 import net.sf.jameleon.result.JameleonTestResult;
24 import net.sf.jameleon.result.TestCaseResult;
25 import net.sf.jameleon.util.JameleonUtility;
26
27 import java.io.IOException;
28 import java.util.Calendar;
29 import java.util.Iterator;
30 import java.util.List;
31
32 /***
33 * Reports the test run results is a simple form, suitable for STD OUT or a simple text file
34 */
35 public class SimpleTestRunReporter extends AbstractTestRunReporter{
36
37 public void reportScriptResult(TestCaseTag tct, TestCaseCounter counter) {
38 try{
39 String scriptName = JameleonUtility.getFileNameFromScriptPath(tct.getFileName());
40 getWriter().write("\n"+ scriptName );
41 TestCaseResult tcr = tct.getResults();
42 if (tcr.failed()){
43 List failedResults = tcr.getFailedResults();
44 JameleonTestResult jtr;
45 for (Iterator it = failedResults.iterator(); it.hasNext();){
46 jtr = (JameleonTestResult)it.next();
47 getWriter().write("\nFunctionId: " + jtr.getIdentifier());
48 getWriter().write("\nLine #: " + jtr.getLineNumber());
49 getWriter().write("\nRow #: " + jtr.getFailedRowNum());
50 getWriter().write("\nError Message: " + jtr.getErrorMsg()+"\n");
51 }
52 getWriter().write(scriptName);
53 }
54 getWriter().write(" : " +tct.getResults().getOutcome());
55 getWriter().flush();
56 }catch(IOException ioe){
57 throw new JameleonException("Could not report simple results: "+ioe.getMessage());
58 }
59 }
60
61 public void reportTestRunComplete(Calendar startTime, Calendar endTime, TestCaseCounter counter) {
62 try{
63 getWriter().write("______________________________________________________\n\n");
64 getWriter().write("Test Run: " + ReporterUtils.formatTime(startTime));
65 getWriter().write("\nTests run: " + counter.getNumRun());
66 getWriter().write(" Failed: " + counter.getNumFailed());
67 getWriter().write(" Time: " + ReporterUtils.getExecutionTime(startTime, endTime));
68 getWriter().write("\n______________________________________________________\n");
69 getWriter().flush();
70 }catch(IOException ioe){
71 throw new JameleonException("Could not report summary results: "+ioe.getMessage());
72 }
73 }
74
75 public void reportTestRunStart(Calendar startTime) {
76
77 }
78
79 }