Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertionPattern issue fixes #36

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/main/kotlin/com/featurevisor/testRunner/TestExecuter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ data class TestProjectOption(
fun startTest(option: TestProjectOption) {
var hasError = false
val folder = File("${option.projectRootPath}/${option.testDirPath}")
val listOfFiles = folder.listFiles()
val listOfFiles = folder.listFiles()?.sortedBy { it }
var executionResult: ExecutionResult? = null
val startTime = System.currentTimeMillis()
var passedTestsCount = 0
Expand Down Expand Up @@ -103,11 +103,18 @@ private fun executeTest(filePath: String, dataFile: DataFile, option: TestProjec

val testResult: TestResult = when (test) {
is Test.Feature -> {
testFeature(test.value, dataFile = dataFile, option)
testFeature(
testFeature = test.value,
dataFile = dataFile,
option = option
)
}

is Test.Segment -> {
testSegment(test.value, option.projectRootPath)
testSegment(
testSegment = test.value,
option = option
)
}
}

Expand Down
22 changes: 13 additions & 9 deletions src/main/kotlin/com/featurevisor/testRunner/TestSegment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import com.featurevisor.types.TestResultAssertion
import com.featurevisor.types.TestResultAssertionError
import com.featurevisor.types.TestSegment

fun testSegment(test: TestSegment, segmentFilePath: String): TestResult {
fun testSegment(testSegment: TestSegment, option: TestProjectOption): TestResult {
val testStartTime = System.currentTimeMillis()
val segmentKey = test.key
val segmentKey = testSegment.key

val testResult = TestResult(
type = "segment",
Expand All @@ -19,22 +19,26 @@ fun testSegment(test: TestSegment, segmentFilePath: String): TestResult {
assertions = mutableListOf()
)

for (aIndex in 0 until test.assertions.size) {
val assertions = getSegmentAssertionsFromMatrix(aIndex, test.assertions[aIndex])
testSegment.assertions.forEachIndexed { index, segmentAssertion ->
val assertions = getSegmentAssertionsFromMatrix(index,segmentAssertion)

for (assertion in assertions) {
assertions.forEach {
val assertionStartTime = System.currentTimeMillis()

val testResultAssertion = TestResultAssertion(
description = assertion.description.orEmpty(),
description = it.description.orEmpty(),
duration = 0,
passed = true,
errors = mutableListOf()
)

val yamlSegment = parseYamlSegment("$segmentFilePath/segments/$segmentKey.yml")
val expected = assertion.expectedToMatch
val actual = segmentIsMatched(yamlSegment!!, assertion.context)
if (option.assertionPattern.isNotEmpty() && !it.description.orEmpty().contains(option.assertionPattern)) {
return@forEach
}

val yamlSegment = parseYamlSegment("${option.projectRootPath}/segments/$segmentKey.yml")
val expected = it.expectedToMatch
val actual = segmentIsMatched(yamlSegment!!, it.context)
val passed = actual == expected

if (!passed) {
Expand Down
Loading