Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
TestRequest |
|
| 1.4285714285714286;1.429 |
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 | * @return A list of java.io.File objects. | |
63 | */ | |
64 | public List getSuiteXmlFiles() | |
65 | { | |
66 | 0 | return suiteXmlFiles; |
67 | } | |
68 | ||
69 | /** | |
70 | * Test source directory, normally ${project.build.testSourceDirectory} | |
71 | * @return A file pointing to test sources | |
72 | */ | |
73 | public File getTestSourceDirectory() | |
74 | { | |
75 | 0 | return testSourceDirectory; |
76 | } | |
77 | ||
78 | /** | |
79 | * A specific test request issued with -Dtest= from the command line. | |
80 | * @return The string specified at the command line | |
81 | */ | |
82 | public String getRequestedTest() | |
83 | { | |
84 | 0 | return requestedTest; |
85 | } | |
86 | ||
87 | /** | |
88 | * A specific test request method issued with -Dtest=class#method from the command line. | |
89 | * @return The string specified at the command line | |
90 | * @since 2.7.3 | |
91 | */ | |
92 | public String getRequestedTestMethod() | |
93 | { | |
94 | 0 | return requestedTestMethod; |
95 | } | |
96 | ||
97 | private static List createFiles( List suiteXmlFiles ) | |
98 | { | |
99 | 0 | if ( suiteXmlFiles != null ) |
100 | { | |
101 | 0 | List files = new ArrayList(); |
102 | Object element; | |
103 | 0 | for ( int i = 0; i < suiteXmlFiles.size(); i++ ) |
104 | { | |
105 | 0 | element = suiteXmlFiles.get( i ); |
106 | 0 | files.add( element instanceof String ? new File( (String) element ) : (File) element ); |
107 | } | |
108 | 0 | return files; |
109 | } | |
110 | 0 | return null; |
111 | } | |
112 | ||
113 | } |