Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
TestRequest |
|
| 1.5714285714285714;1,571 |
1 | package org.apache.maven.surefire.testset; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import java.io.File; | |
23 | import java.util.ArrayList; | |
24 | import java.util.List; | |
25 | ||
26 | /** | |
27 | * Information about the requested test. | |
28 | * | |
29 | * @author Kristian Rosenvold | |
30 | */ | |
31 | public class TestRequest | |
32 | { | |
33 | private final List suiteXmlFiles; | |
34 | ||
35 | private final File testSourceDirectory; | |
36 | ||
37 | private final String requestedTest; | |
38 | ||
39 | /** | |
40 | * @since 2.7.3 | |
41 | */ | |
42 | private final String requestedTestMethod; | |
43 | ||
44 | public TestRequest( List suiteXmlFiles, File testSourceDirectory, String requestedTest ) | |
45 | { | |
46 | 0 | this( suiteXmlFiles, testSourceDirectory, requestedTest, null ); |
47 | 0 | } |
48 | ||
49 | /** | |
50 | * @since 2.7.3 | |
51 | */ | |
52 | public TestRequest( List suiteXmlFiles, File testSourceDirectory, String requestedTest, String requestedTestMethod ) | |
53 | 0 | { |
54 | 0 | this.suiteXmlFiles = createFiles( suiteXmlFiles ); |
55 | 0 | this.testSourceDirectory = testSourceDirectory; |
56 | 0 | this.requestedTest = requestedTest; |
57 | 0 | this.requestedTestMethod = requestedTestMethod; |
58 | 0 | } |
59 | ||
60 | /** | |
61 | * Represents suitexmlfiles that define the test-run request | |
62 | * | |
63 | * @return A list of java.io.File objects. | |
64 | */ | |
65 | public List getSuiteXmlFiles() | |
66 | { | |
67 | 0 | return suiteXmlFiles; |
68 | } | |
69 | ||
70 | /** | |
71 | * Test source directory, normally ${project.build.testSourceDirectory} | |
72 | * | |
73 | * @return A file pointing to test sources | |
74 | */ | |
75 | public File getTestSourceDirectory() | |
76 | { | |
77 | 0 | return testSourceDirectory; |
78 | } | |
79 | ||
80 | /** | |
81 | * A specific test request issued with -Dtest= from the command line. | |
82 | * | |
83 | * @return The string specified at the command line | |
84 | */ | |
85 | public String getRequestedTest() | |
86 | { | |
87 | 0 | return requestedTest; |
88 | } | |
89 | ||
90 | /** | |
91 | * A specific test request method issued with -Dtest=class#method from the command line. | |
92 | * | |
93 | * @return The string specified at the command line | |
94 | * @since 2.7.3 | |
95 | */ | |
96 | public String getRequestedTestMethod() | |
97 | { | |
98 | 0 | return requestedTestMethod; |
99 | } | |
100 | ||
101 | private static List createFiles( List suiteXmlFiles ) | |
102 | { | |
103 | 0 | if ( suiteXmlFiles != null ) |
104 | { | |
105 | 0 | List files = new ArrayList(); |
106 | Object element; | |
107 | 0 | for ( int i = 0; i < suiteXmlFiles.size(); i++ ) |
108 | { | |
109 | 0 | element = suiteXmlFiles.get( i ); |
110 | 0 | files.add( element instanceof String ? new File( (String) element ) : (File) element ); |
111 | } | |
112 | 0 | return files; |
113 | } | |
114 | 0 | return null; |
115 | } | |
116 | ||
117 | } |