EMMA Coverage Report (generated Fri Jul 28 01:51:09 CEST 2006)
[all classes][org.jtiger.report.text]

COVERAGE SUMMARY FOR SOURCE FILE [TextFixtureResultsHandler.java]

nameclass, %method, %block, %line, %
TextFixtureResultsHandler.java100% (1/1)100% (2/2)81%  (65/80)81%  (17/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TextFixtureResultsHandler100% (1/1)100% (2/2)81%  (65/80)81%  (17/21)
TextFixtureResultsHandler (): void 100% (1/1)100% (3/3)100% (2/2)
handleResult (FixtureResults, ReadOnlyArray): void 100% (1/1)81%  (62/77)79%  (15/19)

1/*
2 * JTiger Unit Testing Framework for J2SE 1.5
3 * Copyright (C) 2005 Tony Morris
4 *
5 * This software is licenced under the
6 * Common Public Licence version 1.0
7 * http://www.opensource.org/licenses/cpl1.0.php
8 *
9 * You received a copy of this licence with this software.
10 */
11package org.jtiger.report.text;
12 
13import java.io.FileWriter;
14import java.io.IOException;
15import java.io.PrintWriter;
16import java.io.File;
17import org.jtiger.framework.FixtureResult;
18import org.jtiger.framework.FixtureResults;
19import org.jtiger.framework.FixtureResultsHandler;
20import org.jtiger.framework.FixtureResultsHandlerException;
21import org.jtiger.framework.ReadOnlyArray;
22import org.jtiger.framework.TestResult;
23 
24/**
25 * A result handler that produces a plain text report of test run results.
26 * The report is written to a file which is passed in the parameters to
27 * {@link #handleResult(org.jtiger.framework.FixtureResults, org.jtiger.framework.ReadOnlyArray) the handleResult method}.
28 *
29 * @author %javadoc.author.tag%
30 * @version %version%<br/>
31 *          <i>Build Number %build.number%</i><br/>
32 *          <i>Build Time %build.time% CET (GMT + 1)</i>
33 */
34public final class TextFixtureResultsHandler implements FixtureResultsHandler
35{
36    /**
37     * Create a default <tt>TextFixtureResultsHandler</tt>.
38     */
39    public TextFixtureResultsHandler()
40    {
41 
42    }
43 
44    /**
45     * Write a plain text report of the given test run results to a file which is passed in the parameters.
46     * If the <tt>params</tt> are empty, the current directory is used to write the report to in a file called
47     * 'result.txt'.
48     *
49     * @param results The test run results to produce the plain text report of.
50     * @param params The parameters that contain at least one parameter which is the file to write the plain text report
51     * to otherwise the current directory is used.
52     * @throws FixtureResultsHandlerException If an error occurs while writing the plain text report.
53     */
54    public void handleResult(final FixtureResults results,  final ReadOnlyArray<String> params) throws FixtureResultsHandlerException
55    {
56        final File destination;
57 
58        if(params == null || params.length() == 0)
59        {
60            destination = new File("result.txt");
61        }
62        else
63        {
64            destination = new File(params.get(0));
65        }
66 
67        PrintWriter out = null;
68 
69        try
70        {
71            out = new PrintWriter(new FileWriter(destination));
72 
73            for(FixtureResult result : results)
74            {
75                for(TestResult tr : result)
76                {
77                    out.println(tr);
78                }
79 
80                out.println();
81            }
82        }
83        catch(IOException e)
84        {
85            throw new FixtureResultsHandlerException(e.getMessage(), e);
86        }
87        finally
88        {
89            if(out != null)
90            {
91                out.close();
92            }
93        }
94    }
95 
96}

[all classes][org.jtiger.report.text]
EMMA 2.0.5312 (C) Vladimir Roubtsov