@@ -11,67 +11,21 @@ import java.io.File
1111class CodeQualityToolsPluginDetektTest {
1212 @get:Rule val testProjectDir = TemporaryFolder ()
1313
14+ private val testCode = " package com.vanniktech.test;\n fun foo(param: Int) = param * param\n "
15+ private val testPath = " src/main/kotlin/com/vanniktech/test/Foo.kt"
16+
1417 @Test fun success () {
1518 Roboter (testProjectDir)
1619 .withConfiguration(" failFast: true" )
17- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt" , " fun foo(param: Int) = param * param\n " )
18- .succeeds()
19- }
20-
21- @Test fun successBreakingReportChangeRC9 () {
22- Roboter (testProjectDir, version = " 1.0.0.RC9" )
23- .withConfiguration(" failFast: true" )
24- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt" , " fun foo(param: Int) = param * param\n " )
25- .succeeds()
26- }
27-
28- @Test fun successBreakingReportChangeRC92 () {
29- Roboter (testProjectDir, version = " 1.0.0.RC9.2" )
30- .withConfiguration(" failFast: true" )
31- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt" , " fun foo(param: Int) = param * param\n " )
20+ .withKotlinFile(testPath, testCode)
3221 .succeeds()
3322 }
3423
35- @Test fun successBreakingReportChangeRC10 () {
36- Roboter (testProjectDir, version = " 1.0.0-RC10" )
37- .withConfiguration(" failFast: true" )
38- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt" , " fun foo(param: Int) = param * param\n " )
39- .succeeds()
40- }
41-
42- @Test fun worksWithRC11 () {
43- Roboter (testProjectDir, version = " 1.0.0-RC11" )
44- .withConfiguration(" failFast: true" )
45- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt" , " fun foo(param: Int) = param * param\n " )
46- .succeeds()
47- }
48-
49- @Test fun worksWithRC12 () {
50- Roboter (testProjectDir, version = " 1.0.0-RC12" )
51- .withConfiguration(" failFast: true" )
52- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt" , " fun foo(param: Int) = param * param\n " )
53- .succeeds()
54- }
55-
56- @Test fun worksWithRC13 () {
57- Roboter (testProjectDir, version = " 1.0.0-RC13" )
58- .withConfiguration(" " ) // Fail Fast is configured via the CLI parameter.
59- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt" , " fun foo(param: Int) = param * param\n " )
60- .succeeds()
61- }
62-
63- @Test fun worksWithRC14 () {
64- Roboter (testProjectDir, version = " 1.0.0-RC14" )
65- .withConfiguration(" " ) // Fail Fast is configured via the CLI parameter.
66- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt" , " fun foo(param: Int) = param * param\n " )
67- .succeeds()
68- }
69-
70- @Test fun worksWithRC15 () {
71- Roboter (testProjectDir, version = " 1.0.0-RC15" )
72- .withConfiguration(" " ) // Fail Fast is configured via the CLI parameter.
73- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt" , " package com.vanniktech.test;\n fun foo(param: Int) = param * param\n " )
74- .succeeds()
24+ @Test fun works () {
25+ Roboter (testProjectDir, version = " 1.0.0" )
26+ .withConfiguration(" " ) // Fail Fast is configured via the CLI parameter.
27+ .withKotlinFile(testPath, testCode)
28+ .succeeds()
7529 }
7630
7731 @Test fun noSrcFolder () {
@@ -83,14 +37,14 @@ class CodeQualityToolsPluginDetektTest {
8337 @Test fun differentConfigFile () {
8438 Roboter (testProjectDir, config = " code_quality_tools/config-detekt.yml" )
8539 .withConfiguration(" failFast: true" )
86- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt " , " fun foo(param: Int) = param * param \n " )
40+ .withKotlinFile(testPath, testCode )
8741 .succeeds()
8842 }
8943
9044 @Test fun fails () {
9145 Roboter (testProjectDir)
9246 .withConfiguration(" failFast: true" )
93- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt " , " fun foo() = Unit" )
47+ .withKotlinFile(testPath , " fun foo() = Unit" )
9448 .fails(containsMessage = " NewLineAtEndOfFile - [Foo.kt]" )
9549 }
9650
@@ -111,14 +65,14 @@ class CodeQualityToolsPluginDetektTest {
11165 @Test fun disabled () {
11266 Roboter (testProjectDir, enabled = false )
11367 .withConfiguration(" failFast: true" )
114- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt " , " fun foo() = Unit" )
68+ .withKotlinFile(testPath , " fun foo() = Unit" )
11569 .doesNothing()
11670 }
11771
11872 @Test fun creatingInitialBaselineFails () {
11973 Roboter (testProjectDir, baselineFileName = " detekt-baseline.xml" )
12074 .withConfiguration(" failFast: true" )
121- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt " , " fun foo() = Unit" )
75+ .withKotlinFile(testPath , " fun foo() = Unit" )
12276 .fails(containsMessage = " NewLineAtEndOfFile - [Foo.kt]" )
12377 .baseLineContains(" <ID>NewLineAtEndOfFile:Foo.kt\$ .Foo.kt</ID>" )
12478 }
@@ -131,46 +85,25 @@ class CodeQualityToolsPluginDetektTest {
13185 <SmellBaseline>
13286 <Blacklist timestamp="1529425729991"></Blacklist>
13387 <Whitelist timestamp="1529425729991">
134- <ID>NewLineAtEndOfFile :Foo.kt$.Foo.kt</ID>
88+ <ID>InvalidPackageDeclaration :Foo.kt$.Foo.kt</ID>
13589 </Whitelist>
13690 </SmellBaseline>""" .trimIndent())
137- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt" , " fun foo() = Unit" )
138- .succeeds()
139- }
140-
141- @Test fun mayBeConstSucceedsWithReleaseCandidate7 () {
142- Roboter (testProjectDir, version = " 1.0.0.RC7" )
143- .withConfiguration(" failFast: true" )
144- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt" , """
145- |const val TEST = "test"
146- |val TEST2 = "test" + TEST
147- |""" .trimMargin())
91+ .withKotlinFile(testPath, " fun foo(i: Int) = i * 3\n " )
14892 .succeeds()
14993 }
15094
151- @Test fun mayBeConstFailsWithReleaseCandidate72 () {
152- // RC7-2 fixed this - https://github.com/arturbosch/detekt/pull/930
153- Roboter (testProjectDir, version = " 1.0.0.RC7-2" )
154- .withConfiguration(" failFast: true" )
155- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt" , """
156- |const val TEST = "test"
157- |val TEST2 = "test" + TEST
158- |""" .trimMargin())
159- .fails(containsMessage = " MayBeConst - [TEST2] at" )
160- }
161-
16295 @Test fun checkTaskRunsDetekt () {
16396 Roboter (testProjectDir)
16497 .withConfiguration(" failFast: true" )
165- .withKotlinFile(" src/main/kotlin/com/vanniktech/test/Foo.kt " , " fun foo() = Unit" )
98+ .withKotlinFile(testPath , " fun foo() = Unit" )
16699 .fails(taskToRun = " check" , taskToCheck = " detektCheck" , containsMessage = " NewLineAtEndOfFile - [Foo.kt] at" )
167100 }
168101
169102 class Roboter (
170103 private val directory : TemporaryFolder ,
171104 private val config : String = " code_quality_tools/detekt.yml" ,
172105 enabled : Boolean = true ,
173- version : String = " 1.0.0.RC6 " ,
106+ version : String = " 1.0.0" ,
174107 private val baselineFileName : String? = null
175108 ) {
176109 init {
0 commit comments