From 179e8a7dccdbeb98739910be3c976acedd5bcdda Mon Sep 17 00:00:00 2001 From: Rd Date: Sun, 7 Jul 2024 18:21:27 +0530 Subject: [PATCH] Replaced the TwoSum sample test class name with AddNums --- .../android/scripts/coverage/RunCoverage.kt | 8 +- .../android/scripts/common/BazelClientTest.kt | 26 ++-- .../scripts/coverage/CoverageRunnerTest.kt | 20 +-- .../scripts/coverage/RunCoverageTest.kt | 142 +++++++++--------- 4 files changed, 98 insertions(+), 98 deletions(-) diff --git a/scripts/src/java/org/oppia/android/scripts/coverage/RunCoverage.kt b/scripts/src/java/org/oppia/android/scripts/coverage/RunCoverage.kt index 600700a06ab..eb1c43dbcfd 100644 --- a/scripts/src/java/org/oppia/android/scripts/coverage/RunCoverage.kt +++ b/scripts/src/java/org/oppia/android/scripts/coverage/RunCoverage.kt @@ -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() @@ -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() diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt index ae4b2deee6f..07d1e09c23c 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt @@ -388,7 +388,7 @@ class BazelClientTest { """ package com.example - class TwoSum { + class AddNums { companion object { fun sumNumbers(a: Int, b: Int): Any { @@ -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:: ()V", - "FNDA:1,com/example/TwoSum${'$'}Companion::sumNumbers (II)Ljava/lang/Object;", - "FNDA:0,com/example/TwoSum:: ()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:: ()V", + "FNDA:1,com/example/AddNums${'$'}Companion::sumNumbers (II)Ljava/lang/Object;", + "FNDA:0,com/example/AddNums:: ()V", "FNF:2", "FNH:1", "BRDA:7,0,0,1", diff --git a/scripts/src/javatests/org/oppia/android/scripts/coverage/CoverageRunnerTest.kt b/scripts/src/javatests/org/oppia/android/scripts/coverage/CoverageRunnerTest.kt index 68fd8e7e3e6..4c5ab04dbf0 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/coverage/CoverageRunnerTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/coverage/CoverageRunnerTest.kt @@ -72,7 +72,7 @@ class CoverageRunnerTest { """ package com.example - class TwoSum { + class AddNums { companion object { fun sumNumbers(a: Int, b: Int): Any { @@ -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", @@ -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() diff --git a/scripts/src/javatests/org/oppia/android/scripts/coverage/RunCoverageTest.kt b/scripts/src/javatests/org/oppia/android/scripts/coverage/RunCoverageTest.kt index 41234be70d4..25c193fabfc 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/coverage/RunCoverageTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/coverage/RunCoverageTest.kt @@ -44,7 +44,7 @@ class RunCoverageTest { """ package com.example - class TwoSum { + class AddNums { companion object { fun sumNumbers(a: Int, b: Int): Any { return if (a == 0 && b == 0) { @@ -64,12 +64,12 @@ class RunCoverageTest { 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() @@ -117,12 +117,12 @@ class RunCoverageTest { @Test fun testRunCoverage_ignoreCaseMarkdownArgument_returnsCoverageData() { - val filePath = "coverage/main/java/com/example/TwoSum.kt" + val filePath = "coverage/main/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addSourceAndTestFileWithContent( - filename = "TwoSum", - testFilename = "TwoSumTest", + filename = "AddNums", + testFilename = "AddNumsTest", sourceContent = sourceContent, testContent = testContent, sourceSubpackage = "coverage/main/java/com/example", @@ -144,12 +144,12 @@ class RunCoverageTest { @Test fun testRunCoverage_ignoreCaseHTMLArgument_returnsCoverageData() { - val filePath = "coverage/main/java/com/example/TwoSum.kt" + val filePath = "coverage/main/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addSourceAndTestFileWithContent( - filename = "TwoSum", - testFilename = "TwoSumTest", + filename = "AddNums", + testFilename = "AddNumsTest", sourceContent = sourceContent, testContent = testContent, sourceSubpackage = "coverage/main/java/com/example", @@ -171,12 +171,12 @@ class RunCoverageTest { @Test fun testRunCoverage_reorderedArguments_returnsCoverageData() { - val filePath = "coverage/main/java/com/example/TwoSum.kt" + val filePath = "coverage/main/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addSourceAndTestFileWithContent( - filename = "TwoSum", - testFilename = "TwoSumTest", + filename = "AddNums", + testFilename = "AddNumsTest", sourceContent = sourceContent, testContent = testContent, sourceSubpackage = "coverage/main/java/com/example", @@ -216,12 +216,12 @@ class RunCoverageTest { @Test fun testRunCoverage_sampleTestsDefaultFormat_returnsCoverageData() { - val filePath = "coverage/main/java/com/example/TwoSum.kt" + val filePath = "coverage/main/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addSourceAndTestFileWithContent( - filename = "TwoSum", - testFilename = "TwoSumTest", + filename = "AddNums", + testFilename = "AddNumsTest", sourceContent = sourceContent, testContent = testContent, sourceSubpackage = "coverage/main/java/com/example", @@ -245,12 +245,12 @@ class RunCoverageTest { @Test fun testRunCoverage_sampleTestsMarkdownFormat_returnsCoverageData() { - val filePath = "coverage/main/java/com/example/TwoSum.kt" + val filePath = "coverage/main/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addSourceAndTestFileWithContent( - filename = "TwoSum", - testFilename = "TwoSumTest", + filename = "AddNums", + testFilename = "AddNumsTest", sourceContent = sourceContent, testContent = testContent, sourceSubpackage = "coverage/main/java/com/example", @@ -274,12 +274,12 @@ class RunCoverageTest { @Test fun testRunCoverage_scriptTestsMarkdownFormat_returnsCoverageData() { - val filePath = "scripts/java/com/example/TwoSum.kt" + val filePath = "scripts/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addSourceAndTestFileWithContent( - filename = "TwoSum", - testFilename = "TwoSumTest", + filename = "AddNums", + testFilename = "AddNumsTest", sourceContent = sourceContent, testContent = testContent, sourceSubpackage = "scripts/java/com/example", @@ -303,12 +303,12 @@ class RunCoverageTest { @Test fun testRunCoverage_appTestsMarkdownFormat_returnsCoverageData() { - val filePath = "app/main/java/com/example/TwoSum.kt" + val filePath = "app/main/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addSourceAndTestFileWithContent( - filename = "TwoSum", - testFilename = "TwoSumTest", + filename = "AddNums", + testFilename = "AddNumsTest", sourceContent = sourceContent, testContent = testContent, sourceSubpackage = "app/main/java/com/example", @@ -332,7 +332,7 @@ class RunCoverageTest { @Test fun testRunCoverage_localTestsMarkdownFormat_returnsCoverageData() { - val filePath = "app/main/java/com/example/TwoSum.kt" + val filePath = "app/main/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() val testContentLocal = @@ -342,20 +342,20 @@ class RunCoverageTest { import org.junit.Assert.assertEquals import org.junit.Test - class TwoSumLocalTest { + class AddNumsLocalTest { @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 = "TwoSumLocalTest", + filename = "AddNums", + testFilename = "AddNumsLocalTest", sourceContent = sourceContent, testContent = testContentLocal, sourceSubpackage = "app/main/java/com/example", @@ -379,12 +379,12 @@ class RunCoverageTest { @Test fun testRunCoverage_sharedTestsMarkdownFormat_returnsCoverageData() { - val filePath = "app/main/java/com/example/TwoSum.kt" + val filePath = "app/main/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addSourceAndTestFileWithContent( - filename = "TwoSum", - testFilename = "TwoSumTest", + filename = "AddNums", + testFilename = "AddNumsTest", sourceContent = sourceContent, testContent = testContent, sourceSubpackage = "app/main/java/com/example", @@ -408,7 +408,7 @@ class RunCoverageTest { @Test fun testRunCoverage_sharedAndLocalTestsMarkdownFormat_returnsCoverageData() { - val filePath = "app/main/java/com/example/TwoSum.kt" + val filePath = "app/main/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() val testContentLocal = @@ -418,19 +418,19 @@ class RunCoverageTest { import org.junit.Assert.assertEquals import org.junit.Test - class TwoSumLocalTest { + class AddNumsLocalTest { @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.addMultiLevelSourceAndTestFileWithContent( - filename = "TwoSum", + filename = "AddNums", sourceContent = sourceContent, testContentShared = testContent, testContentLocal = testContentLocal, @@ -454,12 +454,12 @@ class RunCoverageTest { @Test fun testRunCoverage_sampleTestsHTMLFormat_returnsCoverageData() { - val filePath = "coverage/main/java/com/example/TwoSum.kt" + val filePath = "coverage/main/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addSourceAndTestFileWithContent( - filename = "TwoSum", - testFilename = "TwoSumTest", + filename = "AddNums", + testFilename = "AddNumsTest", sourceContent = sourceContent, testContent = testContent, sourceSubpackage = "coverage/main/java/com/example", @@ -483,12 +483,12 @@ class RunCoverageTest { @Test fun testRunCoverage_scriptTestsHTMLFormat_returnsCoverageData() { - val filePath = "scripts/java/com/example/TwoSum.kt" + val filePath = "scripts/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addSourceAndTestFileWithContent( - filename = "TwoSum", - testFilename = "TwoSumTest", + filename = "AddNums", + testFilename = "AddNumsTest", sourceContent = sourceContent, testContent = testContent, sourceSubpackage = "scripts/java/com/example", @@ -512,12 +512,12 @@ class RunCoverageTest { @Test fun testRunCoverage_appTestsHTMLFormat_returnsCoverageData() { - val filePath = "app/main/java/com/example/TwoSum.kt" + val filePath = "app/main/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addSourceAndTestFileWithContent( - filename = "TwoSum", - testFilename = "TwoSumTest", + filename = "AddNums", + testFilename = "AddNumsTest", sourceContent = sourceContent, testContent = testContent, sourceSubpackage = "app/main/java/com/example", @@ -541,7 +541,7 @@ class RunCoverageTest { @Test fun testRunCoverage_localTestsHTMLFormat_returnsCoverageData() { - val filePath = "app/main/java/com/example/TwoSum.kt" + val filePath = "app/main/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() val testContentLocal = @@ -551,20 +551,20 @@ class RunCoverageTest { import org.junit.Assert.assertEquals import org.junit.Test - class TwoSumLocalTest { + class AddNumsLocalTest { @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 = "TwoSumLocalTest", + filename = "AddNums", + testFilename = "AddNumsLocalTest", sourceContent = sourceContent, testContent = testContentLocal, sourceSubpackage = "app/main/java/com/example", @@ -588,12 +588,12 @@ class RunCoverageTest { @Test fun testRunCoverage_sharedTestsHTMLFormat_returnsCoverageData() { - val filePath = "app/main/java/com/example/TwoSum.kt" + val filePath = "app/main/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addSourceAndTestFileWithContent( - filename = "TwoSum", - testFilename = "TwoSumTest", + filename = "AddNums", + testFilename = "AddNumsTest", sourceContent = sourceContent, testContent = testContent, sourceSubpackage = "app/main/java/com/example", @@ -617,7 +617,7 @@ class RunCoverageTest { @Test fun testRunCoverage_sharedAndLocalTestsHTMLFormat_returnsCoverageData() { - val filePath = "app/main/java/com/example/TwoSum.kt" + val filePath = "app/main/java/com/example/AddNums.kt" testBazelWorkspace.initEmptyWorkspace() @@ -628,11 +628,11 @@ class RunCoverageTest { import org.junit.Assert.assertEquals import org.junit.Test - class TwoSumTest { + class AddNumsTest { @Test fun testSumNumbers() { - assertEquals(TwoSum.sumNumbers(0, 1), 1) + assertEquals(AddNums.sumNumbers(0, 1), 1) } } """.trimIndent() @@ -644,18 +644,18 @@ class RunCoverageTest { import org.junit.Assert.assertEquals import org.junit.Test - class TwoSumLocalTest { + class AddNumsLocalTest { @Test fun testSumNumbers() { - assertEquals(TwoSum.sumNumbers(0, 1), 1) - assertEquals(TwoSum.sumNumbers(3, 4), 7) + assertEquals(AddNums.sumNumbers(0, 1), 1) + assertEquals(AddNums.sumNumbers(3, 4), 7) } } """.trimIndent() testBazelWorkspace.addMultiLevelSourceAndTestFileWithContent( - filename = "TwoSum", + filename = "AddNums", sourceContent = sourceContent, testContentShared = testContentShared, testContentLocal = testContentLocal, @@ -664,7 +664,7 @@ class RunCoverageTest { RunCoverage( "${tempFolder.root}", - "app/main/java/com/example/TwoSum.kt", + "app/main/java/com/example/AddNums.kt", ReportFormat.HTML, htmlOutputPath, longCommandExecutor, @@ -806,7 +806,7 @@ class RunCoverageTest { 3 - class TwoSum { + class AddNums { 4 companion object { @@ -994,7 +994,7 @@ class RunCoverageTest { 3 - class TwoSum { + class AddNums { 4 companion object {