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

fix: exclusion of @Suppress test #990

Merged
merged 3 commits into from
Aug 13, 2020
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
2 changes: 2 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## next (unreleased)
- [#987](https://github.com/Flank/flank/pull/987) Flank Error Monitoring readme addition ([sloox](https://github.com/Sloox))
- [#990](https://github.com/Flank/flank/pull/990) Fix: exclusion of @Suppress test. ([piotradamczyk5](https://github.com/piotradamczyk5))
-
-

## v20.08.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.example.test_app

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.Suppress
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -22,9 +23,9 @@ class InstrumentedTest : BaseInstrumentedTest() {

@Test
@Ignore("For testing purpose: https://github.com/Flank/flank/issues/852")
fun ignoredTest1() = testMethod()
fun ignoredTestWithIgnore() = testMethod()

@Test
@Ignore("For testing purpose: https://github.com/Flank/flank/issues/852")
fun ignoredTest2() = testMethod()
@Suppress
fun ignoredTestWitSuppress() = testMethod()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.example.test_app

import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Ignore
import androidx.test.filters.Suppress
import org.junit.Test
import org.junit.runner.RunWith

Expand All @@ -13,9 +14,9 @@ class InstrumentedTest : BaseInstrumentedTest() {

@Test
@Ignore("For testing purpose: https://github.com/Flank/flank/issues/852")
fun ignoredTest() = testMethod()
fun ignoredTestWithIgnore() = testMethod()

@Test
@Ignore("For testing purpose: https://github.com/Flank/flank/issues/852")
fun ignoredTest2() = testMethod()
@Suppress
fun ignoredTestWithSuppress() = testMethod()
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,16 @@ private fun InstrumentationTestContext.getFlankTestMethods(

private fun List<String>.belong(method: TestMethod) = any { className -> method.testName.startsWith(className) }

private fun TestMethod.toFlankTestMethod() = FlankTestMethod("class $testName", ignored = annotations.any { it.name == "org.junit.Ignore" })
private fun TestMethod.toFlankTestMethod() = FlankTestMethod(
testName = "class $testName",
ignored = annotations.any { it.name in ignoredAnnotations }
)

private val ignoredAnnotations = listOf(
"org.junit.Ignore",
"androidx.test.filters.Suppress",
"android.support.test.filters.Suppress"
)

private fun String.toFlankTestMethod() = FlankTestMethod("class $this", ignored = false)

Expand Down
12 changes: 6 additions & 6 deletions test_runner/src/test/kotlin/ftl/run/DumpShardsKtTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class DumpShardsKtTest {
]
},
"junit-ignored": [
"class com.example.test_app.InstrumentedTest#ignoredTest",
"class com.example.test_app.InstrumentedTest#ignoredTest2"
"class com.example.test_app.InstrumentedTest#ignoredTestWithIgnore",
"class com.example.test_app.InstrumentedTest#ignoredTestWithSuppress"
]
},
"matrix-1": {
Expand Down Expand Up @@ -84,8 +84,8 @@ class DumpShardsKtTest {
]
},
"junit-ignored": [
"class com.example.test_app.InstrumentedTest#ignoredTest",
"class com.example.test_app.InstrumentedTest#ignoredTest2"
"class com.example.test_app.InstrumentedTest#ignoredTestWithIgnore",
"class com.example.test_app.InstrumentedTest#ignoredTestWithSuppress"
]
},
"matrix-1": {
Expand All @@ -107,8 +107,8 @@ class DumpShardsKtTest {
]
},
"junit-ignored": [
"class com.example.test_app.InstrumentedTest#ignoredTest1",
"class com.example.test_app.InstrumentedTest#ignoredTest2",
"class com.example.test_app.InstrumentedTest#ignoredTestWithIgnore",
"class com.example.test_app.InstrumentedTest#ignoredTestWithSuppress",
"class com.example.test_app.bar.BarInstrumentedTest#ignoredTestBar",
"class com.example.test_app.foo.FooInstrumentedTest#ignoredTestFoo"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class IgnoreTestsAnnotationTest {
private val singleSuccessYaml = TestHelper.getPath("src/test/kotlin/ftl/fixtures/test_app_cases/flank-single-success.yml")

@Test
fun `InstrumentationContext with @Ignore annotation should have items in ignoredTestCases`() {

fun `InstrumentationContext with @Ignore or @Suppress annotation should have items in ignoredTestCases`() {
val testContext = runBlocking {
AndroidArgs.load(singleSuccessYaml).createAndroidTestContexts()
}.single() as InstrumentationTestContext
Expand All @@ -21,12 +20,21 @@ class IgnoreTestsAnnotationTest {
}

@Test
fun `InstrumentationContext with @Ignore annotation should't have ignoredTestCases in shards`() {
fun `InstrumentationContext with @Ignore annotation shouldn't have ignoredTestCases in shards`() {
val testContext = runBlocking {
AndroidArgs.load(singleSuccessYaml).createAndroidTestContexts()
}.single() as InstrumentationTestContext

Assert.assertFalse(testContext.shards.flatten().any { it.contains("#ignoredTestWithIgnore") })
}

@Test
fun `InstrumentationContext with @Supress annotation shouldn't have ignoredTestCases in shards`() {

val testContext = runBlocking {
AndroidArgs.load(singleSuccessYaml).createAndroidTestContexts()
}.single() as InstrumentationTestContext

Assert.assertFalse(testContext.shards.flatten().any { it.contains("#ignoredTest") })
Assert.assertFalse(testContext.shards.flatten().any { it.contains("#ignoredTestWithSuppress") })
}
}