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

COVERAGE SUMMARY FOR SOURCE FILE [FixtureRunnerFactory.java]

nameclass, %method, %block, %line, %
FixtureRunnerFactory.java100% (2/2)100% (4/4)83%  (134/161)82%  (33/40)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FixtureRunnerFactory100% (1/1)100% (2/2)100% (7/7)100% (3/3)
FixtureRunnerFactory (): void 100% (1/1)100% (3/3)100% (2/2)
newFixtureRunner (): FixtureRunner 100% (1/1)100% (4/4)100% (1/1)
     
class FixtureRunnerFactory$FixtureRunnerImpl100% (1/1)100% (2/2)82%  (127/154)81%  (30/37)
FixtureRunnerFactory$FixtureRunnerImpl (): void 100% (1/1)100% (3/3)100% (2/2)
run (Class, Class, Class, boolean, ReadOnlyArray): FixtureResult 100% (1/1)82%  (124/151)80%  (28/35)

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.framework;
12 
13import static org.jtiger.framework.SequenceFactory.newSequence;
14import java.lang.reflect.InvocationTargetException;
15import java.lang.reflect.Method;
16import java.util.LinkedList;
17import java.util.List;
18import static org.jtiger.framework.TestFailureFactory.newTestFailure;
19import static org.jtiger.framework.FixtureResultFactory.newFixtureResult;
20import static org.jtiger.framework.MethodCategoryFactory.newMethodCategory;
21import static org.jtiger.framework.TestRunnerFactory.newTestRunner;
22import static org.jtiger.framework.ClassConstructionFactory.newClassConstruction;
23import static org.jtiger.framework.DefaultSetUpTearDownFactory.newDefaultSetUpTearDown;
24import static org.jtiger.framework.DefaultTestDefinitionFactory.newDefaultTestDefinition;
25 
26final class FixtureRunnerFactory
27{
28    private FixtureRunnerFactory()
29    {
30 
31    }
32 
33    static FixtureRunner newFixtureRunner()
34    {
35        return new FixtureRunnerImpl();
36    }
37 
38    private static final class FixtureRunnerImpl implements FixtureRunner
39    {
40        FixtureRunnerImpl()
41        {
42 
43        }
44 
45        public FixtureResult run(Class<?> fixtureClass,
46                                 final Class<? extends TestDefinition> definitionClass,
47                                 final Class<? extends SetUpTearDown> sutdClass,
48                                 final boolean haltOnFailure,
49                                 ReadOnlyArray<String> categories)
50                throws RunnerException
51        {
52            if(fixtureClass == null)
53            {
54                return null;
55            }
56 
57            try
58            {
59                TestDefinition definition = newClassConstruction().construct(definitionClass);
60                SetUpTearDown sutd = newClassConstruction().construct(sutdClass);
61 
62                if(definition == null)
63                {
64                    definition = newDefaultTestDefinition();
65                }
66 
67                if(sutd == null)
68                {
69                    sutd = newDefaultSetUpTearDown();
70                }
71 
72                if(categories == null)
73                {
74                    categories = newSequence(new String[0]);
75                }
76 
77                final List<TestResult> results = new LinkedList<TestResult>();
78                final TestRunner runner = newTestRunner();
79                final MethodCategory mc = newMethodCategory();
80 
81                while(fixtureClass != null)
82                {
83                    final Method[] methods = fixtureClass.getDeclaredMethods();
84 
85                    for(Method m : methods)
86                    {
87                        if(definition.isTest(m) &&
88                                mc.isInAnyCategories(m, categories))
89                        {
90                            final Repeat r = m.getAnnotation(Repeat.class);
91 
92                            final long repeat = (r == null || r.value() < 0 ? 1L : r.value());
93 
94                            for(long count = 0; count < repeat; count++)
95                            {
96                                final Object fixture = newClassConstruction().construct(fixtureClass);
97 
98                                final TestResult result = runner.run(m, fixture, sutd);
99 
100                                results.add(result);
101 
102                                final TestFailure tf = newTestFailure();
103 
104                                if(haltOnFailure && tf.isFailure(result.getTestResultType()))
105                                {
106                                    return newFixtureResult(results);
107                                }
108                            }
109                        }
110                    }
111 
112                    fixtureClass = fixtureClass.getSuperclass();
113                }
114 
115                return newFixtureResult(results);
116            }
117            catch(InstantiationException e)
118            {
119                throw new RunnerException(e.getMessage(), e);
120            }
121            catch(IllegalAccessException e)
122            {
123                throw new RunnerException(e.getMessage(), e);
124            }
125            catch(InvocationTargetException e)
126            {
127                throw new RunnerException(e.getMessage(), e);
128            }
129        }
130    }
131}

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