-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4eea509
commit 1d237e6
Showing
3 changed files
with
100 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
com.teamscale.`kotlin-convention` | ||
com.teamscale.`system-test-convention` | ||
com.teamscale.coverage | ||
} | ||
|
82 changes: 0 additions & 82 deletions
82
...-tests/cucumber-maven-tia/src/test/java/com/teamscale/tia/TiaMavenCucumberSystemTest.java
This file was deleted.
Oops, something went wrong.
99 changes: 99 additions & 0 deletions
99
...-tests/cucumber-maven-tia/src/test/kotlin/com/teamscale/tia/TiaMavenCucumberSystemTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package com.teamscale.tia | ||
|
||
import com.teamscale.report.testwise.model.ETestExecutionResult | ||
import com.teamscale.test.commons.SystemTestUtils | ||
import com.teamscale.test.commons.SystemTestUtils.getCoverageString | ||
import com.teamscale.test.commons.SystemTestUtils.runMavenTests | ||
import com.teamscale.test.commons.TeamscaleMockServer | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.Assertions.assertAll | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.function.Executable | ||
import java.util.* | ||
|
||
/** | ||
* Runs several Maven projects' Surefire tests that have the agent attached, and one of our JUnit run listeners enabled. | ||
* Checks that this produces a correct coverage report. | ||
*/ | ||
class TiaMavenCucumberSystemTest { | ||
private var teamscaleMockServer: TeamscaleMockServer? = null | ||
|
||
@BeforeEach | ||
@Throws(Exception::class) | ||
fun startFakeTeamscaleServer() { | ||
teamscaleMockServer?.uploadedReports?.clear() ?: run { | ||
teamscaleMockServer = TeamscaleMockServer(SystemTestUtils.TEAMSCALE_PORT) | ||
.acceptingReportUploads() | ||
.withImpactedTests(*IMPACTED_TEST_PATHS) | ||
} | ||
} | ||
|
||
@AfterEach | ||
fun stopFakeTeamscaleServer() { | ||
teamscaleMockServer?.shutdown() | ||
} | ||
|
||
@Test | ||
@Throws(Exception::class) | ||
fun testMavenTia() { | ||
runMavenTests("maven-project") | ||
|
||
// Check that the partition is correctly recognized | ||
assertThat(teamscaleMockServer?.availableTests) | ||
.extracting("partition") | ||
.contains("MyPartition") | ||
|
||
// Expect a single report upload | ||
assertThat(teamscaleMockServer?.uploadedReports).hasSize(1) | ||
|
||
val unitTestReport = teamscaleMockServer?.parseUploadedTestwiseCoverageReport(0) | ||
assertThat(unitTestReport?.tests).hasSize(IMPACTED_TEST_PATHS.size) | ||
assertThat(unitTestReport?.partial).isTrue() | ||
|
||
// Bundle checks in assertAll to gather all assertions | ||
assertAll( | ||
Executable { | ||
// Check uniform paths in any order | ||
assertThat(unitTestReport?.tests) | ||
.extracting<String> { it.uniformPath } | ||
.containsExactlyInAnyOrder(*IMPACTED_TEST_PATHS) | ||
}, | ||
Executable { | ||
// Verify that all test results are PASSED | ||
assertThat(unitTestReport?.tests) | ||
.extracting<ETestExecutionResult> { it.result } | ||
.containsExactlyInAnyOrder(*IMPACTED_TEST_PATHS.map { ETestExecutionResult.PASSED }.toTypedArray()) | ||
}, | ||
Executable { | ||
// Ensure coverage strings match the expected values | ||
assertThat(unitTestReport?.tests) | ||
.extracting<String> { getCoverageString(it) } | ||
.containsExactly( | ||
COVERAGE_ADD, | ||
COVERAGE_ADD, | ||
COVERAGE_ADD, | ||
COVERAGE_ADD, | ||
COVERAGE_ADD, | ||
COVERAGE_SUBTRACT | ||
) | ||
} | ||
) | ||
Check warning on line 82 in system-tests/cucumber-maven-tia/src/test/kotlin/com/teamscale/tia/TiaMavenCucumberSystemTest.kt
|
||
} | ||
|
||
|
||
companion object { | ||
private val IMPACTED_TEST_PATHS = arrayOf( // sorted alphabetically | ||
"hellocucumber/RunCucumberTest/hellocucumber/calculator.feature/Actually we just want to test a http:\\/\\/link #1", // also tests addition, escaped / | ||
"hellocucumber/RunCucumberTest/hellocucumber/calculator.feature/Add two numbers #1", | ||
"hellocucumber/RunCucumberTest/hellocucumber/calculator.feature/Add two numbers #2", | ||
"hellocucumber/RunCucumberTest/hellocucumber/calculator.feature/Add two numbers #3", | ||
"hellocucumber/RunCucumberTest/hellocucumber/calculator.feature/Add two numbers #4", | ||
"hellocucumber/RunCucumberTest/hellocucumber/calculator.feature/Subtract two numbers 99 & 99 #1" | ||
) | ||
|
||
private const val COVERAGE_ADD = "Calculator.java:3,5;StepDefinitions.java:12,24-25,29-30,39-40" | ||
private const val COVERAGE_SUBTRACT = "Calculator.java:3,9;StepDefinitions.java:12,24-25,34-35,39-40" | ||
} | ||
} |