1 package leakcanary
2 
3 import leakcanary.LeakAssertions.NO_TAG
4 import leakcanary.SkipLeakDetection.Companion.shouldSkipTest
5 import org.assertj.core.api.Assertions.assertThat
6 import org.junit.Rule
7 import org.junit.Test
8 
9 class SkipLeakDetectionTest {
10 
11   @get:Rule
12   val rule = TestDescriptionHolder
13 
14   @SkipLeakDetection("")
testAnnotatedSkipsLeakDetectionnull15   @Test fun testAnnotatedSkipsLeakDetection() {
16     assertThat(shouldSkipTest(TestDescriptionHolder.testDescription, NO_TAG)).isTrue()
17   }
18 
testNotAnnotatedDoesNotSkipLeakDetectionnull19   @Test fun testNotAnnotatedDoesNotSkipLeakDetection() {
20     assertThat(shouldSkipTest(TestDescriptionHolder.testDescription, NO_TAG)).isFalse()
21   }
22 
23   @SkipLeakDetection("")
testAnnotatedSkipsLeakDetectionForTagnull24   @Test fun testAnnotatedSkipsLeakDetectionForTag() {
25     assertThat(shouldSkipTest(TestDescriptionHolder.testDescription, "tag")).isTrue()
26   }
27 
28   @SkipLeakDetection("", "tag")
testAnnotatedSkipsLeakDetectionForTargetTagnull29   @Test fun testAnnotatedSkipsLeakDetectionForTargetTag() {
30     assertThat(shouldSkipTest(TestDescriptionHolder.testDescription, "tag")).isTrue()
31   }
32 
33   @SkipLeakDetection("", "tag1", "tag2")
testAnnotatedDoesNotSkipLeakDetectionForUnlistedTagnull34   @Test fun testAnnotatedDoesNotSkipLeakDetectionForUnlistedTag() {
35     assertThat(shouldSkipTest(TestDescriptionHolder.testDescription, "tag")).isFalse()
36   }
37 
38   @SkipLeakDetection("", "tag1", "tag2")
testAnnotatedSkipsLeakDetectionForListedTagnull39   @Test fun testAnnotatedSkipsLeakDetectionForListedTag() {
40     assertThat(shouldSkipTest(TestDescriptionHolder.testDescription, "tag2")).isTrue()
41   }
42 }
43