Skip to content

Commit f6007e5

Browse files
fix: exclusion of @Suppress test (Flank#990)
* Flank#984 Added @Suppress test as ignored * Update release notes * Fix tests
1 parent 824eea3 commit f6007e5

File tree

6 files changed

+38
-17
lines changed

6 files changed

+38
-17
lines changed

release_notes.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## next (unreleased)
22
- [#987](https://github.com/Flank/flank/pull/987) Flank Error Monitoring readme addition ([sloox](https://github.com/Sloox))
3+
- [#990](https://github.com/Flank/flank/pull/990) Fix: exclusion of @Suppress test. ([piotradamczyk5](https://github.com/piotradamczyk5))
4+
-
35
-
46

57
## v20.08.1

test_projects/android/app/src/androidTestMultiple/java/com.example.test_app/InstrumentedTest.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.example.test_app
22

33
import androidx.test.ext.junit.runners.AndroidJUnit4
4+
import androidx.test.filters.Suppress
45
import org.junit.Ignore
56
import org.junit.Test
67
import org.junit.runner.RunWith
@@ -22,9 +23,9 @@ class InstrumentedTest : BaseInstrumentedTest() {
2223

2324
@Test
2425
@Ignore("For testing purpose: https://github.com/Flank/flank/issues/852")
25-
fun ignoredTest1() = testMethod()
26+
fun ignoredTestWithIgnore() = testMethod()
2627

2728
@Test
28-
@Ignore("For testing purpose: https://github.com/Flank/flank/issues/852")
29-
fun ignoredTest2() = testMethod()
29+
@Suppress
30+
fun ignoredTestWitSuppress() = testMethod()
3031
}

test_projects/android/app/src/androidTestSingle/java/com.example.test_app/InstrumentedTest.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.example.test_app
22

33
import androidx.test.ext.junit.runners.AndroidJUnit4
44
import org.junit.Ignore
5+
import androidx.test.filters.Suppress
56
import org.junit.Test
67
import org.junit.runner.RunWith
78

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

1415
@Test
1516
@Ignore("For testing purpose: https://github.com/Flank/flank/issues/852")
16-
fun ignoredTest() = testMethod()
17+
fun ignoredTestWithIgnore() = testMethod()
1718

1819
@Test
19-
@Ignore("For testing purpose: https://github.com/Flank/flank/issues/852")
20-
fun ignoredTest2() = testMethod()
20+
@Suppress
21+
fun ignoredTestWithSuppress() = testMethod()
2122
}

test_runner/src/main/kotlin/ftl/run/platform/android/CreateAndroidTestContext.kt

+10-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,16 @@ private fun InstrumentationTestContext.getFlankTestMethods(
7373

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

76-
private fun TestMethod.toFlankTestMethod() = FlankTestMethod("class $testName", ignored = annotations.any { it.name == "org.junit.Ignore" })
76+
private fun TestMethod.toFlankTestMethod() = FlankTestMethod(
77+
testName = "class $testName",
78+
ignored = annotations.any { it.name in ignoredAnnotations }
79+
)
80+
81+
private val ignoredAnnotations = listOf(
82+
"org.junit.Ignore",
83+
"androidx.test.filters.Suppress",
84+
"android.support.test.filters.Suppress"
85+
)
7786

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

test_runner/src/test/kotlin/ftl/run/DumpShardsKtTest.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class DumpShardsKtTest {
2828
]
2929
},
3030
"junit-ignored": [
31-
"class com.example.test_app.InstrumentedTest#ignoredTest",
32-
"class com.example.test_app.InstrumentedTest#ignoredTest2"
31+
"class com.example.test_app.InstrumentedTest#ignoredTestWithIgnore",
32+
"class com.example.test_app.InstrumentedTest#ignoredTestWithSuppress"
3333
]
3434
},
3535
"matrix-1": {
@@ -84,8 +84,8 @@ class DumpShardsKtTest {
8484
]
8585
},
8686
"junit-ignored": [
87-
"class com.example.test_app.InstrumentedTest#ignoredTest",
88-
"class com.example.test_app.InstrumentedTest#ignoredTest2"
87+
"class com.example.test_app.InstrumentedTest#ignoredTestWithIgnore",
88+
"class com.example.test_app.InstrumentedTest#ignoredTestWithSuppress"
8989
]
9090
},
9191
"matrix-1": {
@@ -107,8 +107,8 @@ class DumpShardsKtTest {
107107
]
108108
},
109109
"junit-ignored": [
110-
"class com.example.test_app.InstrumentedTest#ignoredTest1",
111-
"class com.example.test_app.InstrumentedTest#ignoredTest2",
110+
"class com.example.test_app.InstrumentedTest#ignoredTestWithIgnore",
111+
"class com.example.test_app.InstrumentedTest#ignoredTestWithSuppress",
112112
"class com.example.test_app.bar.BarInstrumentedTest#ignoredTestBar",
113113
"class com.example.test_app.foo.FooInstrumentedTest#ignoredTestFoo"
114114
]

test_runner/src/test/kotlin/ftl/run/platform/android/IgnoreTestsAnnotationTest.kt

+12-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ class IgnoreTestsAnnotationTest {
1111
private val singleSuccessYaml = TestHelper.getPath("src/test/kotlin/ftl/fixtures/test_app_cases/flank-single-success.yml")
1212

1313
@Test
14-
fun `InstrumentationContext with @Ignore annotation should have items in ignoredTestCases`() {
15-
14+
fun `InstrumentationContext with @Ignore or @Suppress annotation should have items in ignoredTestCases`() {
1615
val testContext = runBlocking {
1716
AndroidArgs.load(singleSuccessYaml).createAndroidTestContexts()
1817
}.single() as InstrumentationTestContext
@@ -21,12 +20,21 @@ class IgnoreTestsAnnotationTest {
2120
}
2221

2322
@Test
24-
fun `InstrumentationContext with @Ignore annotation should't have ignoredTestCases in shards`() {
23+
fun `InstrumentationContext with @Ignore annotation shouldn't have ignoredTestCases in shards`() {
24+
val testContext = runBlocking {
25+
AndroidArgs.load(singleSuccessYaml).createAndroidTestContexts()
26+
}.single() as InstrumentationTestContext
27+
28+
Assert.assertFalse(testContext.shards.flatten().any { it.contains("#ignoredTestWithIgnore") })
29+
}
30+
31+
@Test
32+
fun `InstrumentationContext with @Supress annotation shouldn't have ignoredTestCases in shards`() {
2533

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

30-
Assert.assertFalse(testContext.shards.flatten().any { it.contains("#ignoredTest") })
38+
Assert.assertFalse(testContext.shards.flatten().any { it.contains("#ignoredTestWithSuppress") })
3139
}
3240
}

0 commit comments

Comments
 (0)