Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
TestsToRun |
|
| 0.0;0 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | package org.apache.maven.surefire.junitcore; | |
20 | ||
21 | import org.apache.maven.surefire.testset.TestSetFailedException; | |
22 | ||
23 | import java.util.Collections; | |
24 | import java.util.HashMap; | |
25 | import java.util.Map; | |
26 | ||
27 | /** | |
28 | * Contains all the tests that have been found according to specified include/exclude | |
29 | * specification for a given surefire run. | |
30 | * | |
31 | * @author Kristian Rosenvold (junit core adaption) | |
32 | */ | |
33 | class TestsToRun | |
34 | { | |
35 | final Class[] locatedClasses; | |
36 | ||
37 | final int totalTests; | |
38 | ||
39 | Map<String, JUnitCoreTestSet> testSets; | |
40 | ||
41 | public TestsToRun( Class... locatedClasses ) | |
42 | throws TestSetFailedException | |
43 | 0 | { |
44 | 0 | this.locatedClasses = locatedClasses; |
45 | 0 | testSets = new HashMap<String, JUnitCoreTestSet>(); |
46 | 0 | int testCount = 0; |
47 | 0 | for ( Class testClass : locatedClasses ) |
48 | { | |
49 | 0 | JUnitCoreTestSet testSet = new JUnitCoreTestSet( testClass ); |
50 | ||
51 | 0 | if ( testSets.containsKey( testSet.getName() ) ) |
52 | { | |
53 | 0 | throw new TestSetFailedException( "Duplicate test set '" + testSet.getName() + "'" ); |
54 | } | |
55 | 0 | testSets.put( testSet.getName(), testSet ); |
56 | 0 | testCount++; |
57 | } | |
58 | 0 | this.totalTests = testCount; |
59 | 0 | } |
60 | ||
61 | public Map<String, JUnitCoreTestSet> getTestSets() | |
62 | { | |
63 | 0 | return Collections.unmodifiableMap( testSets ); |
64 | } | |
65 | ||
66 | public int size() | |
67 | { | |
68 | 0 | return testSets.size(); |
69 | } | |
70 | ||
71 | public Class[] getLocatedClasses() | |
72 | { | |
73 | 0 | return locatedClasses; |
74 | } | |
75 | ||
76 | public JUnitCoreTestSet getTestSet( String name ) | |
77 | { | |
78 | 0 | return testSets.get( name ); |
79 | } | |
80 | ||
81 | } |