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 | */ |
11 | package org.jtiger.framework; |
12 | |
13 | import static org.jtiger.framework.TestResultType.SUCCESS; |
14 | import static org.jtiger.framework.TestFailureFactory.newTestFailure; |
15 | import static org.jtiger.framework.TestIgnoredFactory.newTestIgnored; |
16 | |
17 | /** |
18 | * The default implementation to handle fixture results sends output to |
19 | * <a href="%j2se.api.spec%/java/lang/System.html#out">the standard output stream</a> with a summary of the result. |
20 | * The summary contains the number of test case results of success, failure and ignored. |
21 | * |
22 | * @author %javadoc.author.tag% |
23 | * @version %version%<br/> |
24 | * <i>Build Number %build.number%</i><br/> |
25 | * <i>Build Time %build.time% CET (GMT + 1)</i> |
26 | */ |
27 | public final class DefaultFixtureResultsHandlerFactory |
28 | { |
29 | private DefaultFixtureResultsHandlerFactory() |
30 | { |
31 | |
32 | } |
33 | |
34 | /** |
35 | * Returns a new instance of the default implementation to handle fixture results. |
36 | * |
37 | * @return A new instance of the default implementation to handle fixture results. |
38 | */ |
39 | public static FixtureResultsHandler newDefaultFixtureResultsHandler() |
40 | { |
41 | return new DefaultFixtureResultsHandlerImpl(); |
42 | } |
43 | |
44 | private static final class DefaultFixtureResultsHandlerImpl implements FixtureResultsHandler |
45 | { |
46 | DefaultFixtureResultsHandlerImpl() |
47 | { |
48 | |
49 | } |
50 | |
51 | public void handleResult(final FixtureResults results, final ReadOnlyArray<String> params) |
52 | { |
53 | int failures = 0; |
54 | int successes = 0; |
55 | int ignored = 0; |
56 | |
57 | for(FixtureResult result : results) |
58 | { |
59 | for(TestResult tr : result) |
60 | { |
61 | if(tr.getTestResultType() == SUCCESS) |
62 | { |
63 | successes++; |
64 | } |
65 | else if(newTestFailure().isFailure(tr.getTestResultType())) |
66 | { |
67 | failures++; |
68 | } |
69 | else if(newTestIgnored().isIgnored(tr.getTestResultType())) |
70 | { |
71 | ignored++; |
72 | } |
73 | } |
74 | } |
75 | |
76 | System.out.println(DefaultFixtureResultsHandlerMessage.message(successes, failures, ignored)); |
77 | } |
78 | } |
79 | } |