Skip to content

Commit

Permalink
Replaced the TwoSum sample test class name with AddNums
Browse files Browse the repository at this point in the history
  • Loading branch information
Rd4dev committed Jul 7, 2024
1 parent 49b8e0f commit 179e8a7
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ class RunCoverage(
val coverageReports = deferredCoverageReports.awaitAll()

/*val coverageReports = listOf(CoverageReport.newBuilder()
.setBazelTestTarget("//coverage/test/java/com/example:TwoSumTest")
.setFilePath("coverage/main/java/com/example/TwoSum.kt")
.setBazelTestTarget("//coverage/test/java/com/example:AddNumsTest")
.setFilePath("coverage/main/java/com/example/AddNums.kt")
.setFileSha1Hash("1020b8f405555b3f4537fd07b912d3fb9ffa3354")
.addCoveredLine(
CoveredLine.newBuilder()
Expand Down Expand Up @@ -165,8 +165,8 @@ class RunCoverage(
.setLinesHit(2)
.build(),
CoverageReport.newBuilder()
.setBazelTestTarget("//coverage/test/java/com/example:TwoSumLocalTest")
.setFilePath("coverage/main/java/com/example/TwoSum.kt")
.setBazelTestTarget("//coverage/test/java/com/example:AddNumsLocalTest")
.setFilePath("coverage/main/java/com/example/AddNums.kt")
.setFileSha1Hash("1020b8f405555b3f4537fd07b912d3fb9ffa3354")
.addCoveredLine(
CoveredLine.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class BazelClientTest {
"""
package com.example
class TwoSum {
class AddNums {
companion object {
fun sumNumbers(a: Int, b: Int): Any {
Expand All @@ -409,33 +409,33 @@ class BazelClientTest {
import org.junit.Assert.assertEquals
import org.junit.Test
class TwoSumTest {
class AddNumsTest {
@Test
fun testSumNumbers() {
assertEquals(TwoSum.sumNumbers(0, 1), 1)
assertEquals(TwoSum.sumNumbers(3, 4), 7)
assertEquals(TwoSum.sumNumbers(0, 0), "Both numbers are zero")
assertEquals(AddNums.sumNumbers(0, 1), 1)
assertEquals(AddNums.sumNumbers(3, 4), 7)
assertEquals(AddNums.sumNumbers(0, 0), "Both numbers are zero")
}
}
""".trimIndent()

testBazelWorkspace.addSourceAndTestFileWithContent(
filename = "TwoSum",
testFilename = "TwoSumTest",
filename = "AddNums",
testFilename = "AddNumsTest",
sourceContent = sourceContent,
testContent = testContent,
sourceSubpackage = "coverage/main/java/com/example",
testSubpackage = "coverage/test/java/com/example"
)

val result = bazelClient.runCoverageForTestTarget("//coverage/test/java/com/example:TwoSumTest")
val result = bazelClient.runCoverageForTestTarget("//coverage/test/java/com/example:AddNumsTest")
val expectedResult = listOf(
"SF:coverage/main/java/com/example/TwoSum.kt",
"FN:7,com/example/TwoSum${'$'}Companion::sumNumbers (II)Ljava/lang/Object;",
"FN:3,com/example/TwoSum::<init> ()V",
"FNDA:1,com/example/TwoSum${'$'}Companion::sumNumbers (II)Ljava/lang/Object;",
"FNDA:0,com/example/TwoSum::<init> ()V",
"SF:coverage/main/java/com/example/AddNums.kt",
"FN:7,com/example/AddNums${'$'}Companion::sumNumbers (II)Ljava/lang/Object;",
"FN:3,com/example/AddNums::<init> ()V",
"FNDA:1,com/example/AddNums${'$'}Companion::sumNumbers (II)Ljava/lang/Object;",
"FNDA:0,com/example/AddNums::<init> ()V",
"FNF:2",
"FNH:1",
"BRDA:7,0,0,1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class CoverageRunnerTest {
"""
package com.example
class TwoSum {
class AddNums {
companion object {
fun sumNumbers(a: Int, b: Int): Any {
Expand All @@ -93,20 +93,20 @@ class CoverageRunnerTest {
import org.junit.Assert.assertEquals
import org.junit.Test
class TwoSumTest {
class AddNumsTest {
@Test
fun testSumNumbers() {
assertEquals(TwoSum.sumNumbers(0, 1), 1)
assertEquals(TwoSum.sumNumbers(3, 4), 7)
assertEquals(TwoSum.sumNumbers(0, 0), "Both numbers are zero")
assertEquals(AddNums.sumNumbers(0, 1), 1)
assertEquals(AddNums.sumNumbers(3, 4), 7)
assertEquals(AddNums.sumNumbers(0, 0), "Both numbers are zero")
}
}
""".trimIndent()

testBazelWorkspace.addSourceAndTestFileWithContent(
filename = "TwoSum",
testFilename = "TwoSumTest",
filename = "AddNums",
testFilename = "AddNumsTest",
sourceContent = sourceContent,
testContent = testContent,
sourceSubpackage = "coverage/main/java/com/example",
Expand All @@ -115,13 +115,13 @@ class CoverageRunnerTest {

val result = runBlocking {
coverageRunner.runWithCoverageAsync(
"//coverage/test/java/com/example:TwoSumTest"
"//coverage/test/java/com/example:AddNumsTest"
).await()
}

val expectedResult = CoverageReport.newBuilder()
.setBazelTestTarget("//coverage/test/java/com/example:TwoSumTest")
.setFilePath("coverage/main/java/com/example/TwoSum.kt")
.setBazelTestTarget("//coverage/test/java/com/example:AddNumsTest")
.setFilePath("coverage/main/java/com/example/AddNums.kt")
.setFileSha1Hash("1020b8f405555b3f4537fd07b912d3fb9ffa3354")
.addCoveredLine(
CoveredLine.newBuilder()
Expand Down
Loading

0 comments on commit 179e8a7

Please sign in to comment.