@@ -2,67 +2,62 @@ package com.featurevisor.tasks
2
2
3
3
import org.gradle.api.DefaultTask
4
4
import org.gradle.api.tasks.Input
5
- import org.gradle.api.tasks.Optional
6
5
import org.gradle.api.tasks.TaskAction
7
6
import com.featurevisor.testRunner.*
7
+ import org.gradle.api.tasks.options.Option
8
8
9
9
open class RunAllTestsTask : DefaultTask () {
10
10
11
11
companion object {
12
- const val NAME = " run- test"
12
+ const val NAME = " test"
13
13
}
14
14
15
15
@Input
16
- @Optional
17
- var rootProjectPath: String? = null
16
+ @Option(option = " rootProjectPath " , description = " Whether to run test for specific project " )
17
+ var rootProjectPath: String = project.projectDir.absolutePath
18
18
19
19
@Input
20
- @Optional
21
- var testDirPath: String? = null
20
+ @Option(option = " testDirPath " , description = " Whether to run test for specific test directory " )
21
+ var testDirPath: String = " tests "
22
22
23
23
@Input
24
- @Optional
25
- var featureName : String? = null
24
+ @Option(option = " keyPattern " , description = " Run test for specific key pattern " )
25
+ var keyPattern : String = " "
26
26
27
27
@Input
28
- @Optional
29
- var segmentName : String? = null
28
+ @Option(option = " assertionPattern " , description = " Run test for specific assertion pattern " )
29
+ var assertionPattern : String = " "
30
30
31
- @TaskAction
32
- fun executeTask () {
33
-
34
- when {
35
- (rootProjectPath.isNullOrEmpty().not () && testDirPath.isNullOrEmpty().not ()) -> {
36
- startTest(rootProjectPath.orEmpty(), testDirPath.orEmpty())
37
- }
38
-
39
- (rootProjectPath.isNullOrEmpty().not () && featureName.isNullOrEmpty().not ()) -> {
40
- testSingleFeature(featureKey = featureName.orEmpty(), projectRootPath = rootProjectPath.orEmpty())
41
- }
42
-
43
- (rootProjectPath.isNullOrEmpty().not () && segmentName.isNullOrEmpty().not ()) -> {
44
- testSingleSegment(segmentKey = segmentName.orEmpty(), projectRootPath = rootProjectPath.orEmpty())
45
- }
31
+ @Input
32
+ @Option(option = " verbose" , description = " Whether to run tests in verbose mode" )
33
+ var verbose: Boolean = false
46
34
47
- rootProjectPath.isNullOrEmpty(). not () -> {
48
- startTest(projectRootPath = rootProjectPath.orEmpty() )
49
- }
35
+ @Input
36
+ @Option(option = " showDatafile " , description = " Whether to run tests by showing datafile " )
37
+ var showDatafile : Boolean = false
50
38
51
- testDirPath.isNullOrEmpty(). not () -> {
52
- startTest(testDirPath = testDirPath.orEmpty(), projectRootPath = project.projectDir.absolutePath )
53
- }
39
+ @Input
40
+ @Option(option = " onlyFailures " , description = " Whether to run tests by showing only failed tests " )
41
+ var onlyFailures : Boolean = false
54
42
55
- featureName.isNullOrEmpty(). not () -> {
56
- testSingleFeature(featureKey = featureName.orEmpty(), projectRootPath = project.projectDir.absolutePath )
57
- }
43
+ @Input
44
+ @Option(option = " fast " , description = " Whether to run tests in fast mode " )
45
+ var fast : Boolean = false
58
46
59
- segmentName.isNullOrEmpty().not () -> {
60
- testSingleSegment(segmentKey = segmentName.orEmpty(), projectRootPath = project.projectDir.absolutePath)
61
- }
47
+ @TaskAction
48
+ fun executeTask () {
62
49
63
- else -> {
64
- startTest(projectRootPath = project.projectDir.absolutePath)
65
- }
66
- }
50
+ val testProjectOption = TestProjectOption (
51
+ keyPattern = keyPattern,
52
+ assertionPattern = assertionPattern,
53
+ verbose = verbose,
54
+ showDatafile = showDatafile,
55
+ onlyFailures = onlyFailures,
56
+ fast = fast,
57
+ projectRootPath = rootProjectPath,
58
+ testDirPath = testDirPath
59
+ )
60
+
61
+ startTest(testProjectOption)
67
62
}
68
63
}
0 commit comments