@@ -6,9 +6,9 @@ import com.featurevisor.types.TestResultAssertion
6
6
import com.featurevisor.types.TestResultAssertionError
7
7
import com.featurevisor.types.TestSegment
8
8
9
- fun testSegment (test : TestSegment , segmentFilePath : String ): TestResult {
9
+ fun testSegment (testSegment : TestSegment , option : TestProjectOption ): TestResult {
10
10
val testStartTime = System .currentTimeMillis()
11
- val segmentKey = test .key
11
+ val segmentKey = testSegment .key
12
12
13
13
val testResult = TestResult (
14
14
type = " segment" ,
@@ -19,22 +19,26 @@ fun testSegment(test: TestSegment, segmentFilePath: String): TestResult {
19
19
assertions = mutableListOf ()
20
20
)
21
21
22
- for (aIndex in 0 until test .assertions.size) {
23
- val assertions = getSegmentAssertionsFromMatrix(aIndex, test.assertions[aIndex] )
22
+ testSegment .assertions.forEachIndexed { index, segmentAssertion ->
23
+ val assertions = getSegmentAssertionsFromMatrix(index,segmentAssertion )
24
24
25
- for (assertion in assertions) {
25
+ assertions.forEach {
26
26
val assertionStartTime = System .currentTimeMillis()
27
27
28
28
val testResultAssertion = TestResultAssertion (
29
- description = assertion .description.orEmpty(),
29
+ description = it .description.orEmpty(),
30
30
duration = 0 ,
31
31
passed = true ,
32
32
errors = mutableListOf ()
33
33
)
34
34
35
- val yamlSegment = parseYamlSegment(" $segmentFilePath /segments/$segmentKey .yml" )
36
- val expected = assertion.expectedToMatch
37
- val actual = segmentIsMatched(yamlSegment!! , assertion.context)
35
+ if (option.assertionPattern.isNotEmpty() && ! it.description.orEmpty().contains(option.assertionPattern)) {
36
+ return @forEach
37
+ }
38
+
39
+ val yamlSegment = parseYamlSegment(" ${option.projectRootPath} /segments/$segmentKey .yml" )
40
+ val expected = it.expectedToMatch
41
+ val actual = segmentIsMatched(yamlSegment!! , it.context)
38
42
val passed = actual == expected
39
43
40
44
if (! passed) {
0 commit comments