-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48d30e5
commit cd0c3ca
Showing
3 changed files
with
156 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
src/test/kotlin/com/coditory/gradle/integration/acceptance/LombokAcceptanceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
package com.coditory.gradle.integration.acceptance | ||
|
||
import com.coditory.gradle.integration.base.TestProjectBuilder.Companion.project | ||
import com.coditory.gradle.integration.base.TestProjectRunner.runGradle | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.gradle.api.Project | ||
import org.gradle.testkit.runner.TaskOutcome | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.ValueSource | ||
|
||
class LombokAcceptanceTest { | ||
private val project = createProject() | ||
|
||
private fun createProject(): Project { | ||
val commonImports = | ||
""" | ||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
""".trimIndent() | ||
return project("sample-lombok-project") | ||
.withBuildGradle( | ||
""" | ||
plugins { | ||
id 'com.coditory.integration-test' | ||
} | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
compileOnly "org.projectlombok:lombok:1.18.20" | ||
annotationProcessor "org.projectlombok:lombok:1.18.20" | ||
testCompileOnly "org.projectlombok:lombok:1.18.20" | ||
testAnnotationProcessor "org.projectlombok:lombok:1.18.20" | ||
testImplementation "org.junit.jupiter:junit-jupiter-api:5.5.1" | ||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.5.1" | ||
} | ||
test { | ||
useJUnitPlatform() | ||
testLogging { | ||
events("passed", "failed", "skipped") | ||
setExceptionFormat("full") | ||
} | ||
} | ||
""" | ||
).withFile( | ||
"src/main/java/MainValueExample.java", | ||
""" | ||
import lombok.Value; | ||
@Value | ||
public class MainValueExample { | ||
private final String name; | ||
} | ||
""" | ||
).withFile( | ||
"src/test/java/TestValueExample.java", | ||
""" | ||
import lombok.Value; | ||
@Value | ||
public class TestValueExample { | ||
private final String name; | ||
} | ||
""" | ||
).withFile( | ||
"src/integration/java/IntgValueExample.java", | ||
""" | ||
import lombok.Value; | ||
@Value | ||
public class IntgValueExample { | ||
private final String name; | ||
} | ||
""" | ||
).withFile( | ||
"src/integration/java/TestIntgSpec.java", | ||
""" | ||
$commonImports | ||
public class TestIntgSpec { | ||
@Test | ||
public void shouldValueObjectsFromMain() { | ||
assertEquals(new MainValueExample("X"), new MainValueExample("X")); | ||
assertNotEquals(new MainValueExample("X"), new MainValueExample("Y")); | ||
} | ||
@Test | ||
public void shouldValueObjectsFromTest() { | ||
assertEquals(new TestValueExample("X"), new TestValueExample("X")); | ||
assertNotEquals(new TestValueExample("X"), new TestValueExample("Y")); | ||
} | ||
@Test | ||
public void shouldValueObjectsFromIntegration() { | ||
assertEquals(new IntgValueExample("X"), new IntgValueExample("X")); | ||
assertNotEquals(new IntgValueExample("X"), new IntgValueExample("Y")); | ||
} | ||
} | ||
""" | ||
).withFile( | ||
"src/test/java/TestUnitSpec.java", | ||
""" | ||
$commonImports | ||
public class TestUnitSpec { | ||
@Test | ||
public void shouldValueObjectsFromMain() { | ||
assertEquals(new MainValueExample("X"), new MainValueExample("X")); | ||
assertNotEquals(new MainValueExample("X"), new MainValueExample("Y")); | ||
} | ||
@Test | ||
public void shouldValueObjectsFromTest() { | ||
assertEquals(new TestValueExample("X"), new TestValueExample("X")); | ||
assertNotEquals(new TestValueExample("X"), new TestValueExample("Y")); | ||
} | ||
} | ||
""" | ||
) | ||
.build() | ||
} | ||
|
||
@ParameterizedTest(name = "should run unit tests and integration tests on check command for gradle {0}") | ||
@ValueSource(strings = ["current", "6.0"]) | ||
fun `should run unit tests and integration tests with lombok`(gradleVersion: String?) { | ||
// when | ||
val result = runGradle(project, listOf("check"), gradleVersion) | ||
// then | ||
assertThat(result.task(":test")?.outcome).isEqualTo(TaskOutcome.SUCCESS) | ||
assertThat(result.task(":integrationTest")?.outcome).isEqualTo(TaskOutcome.SUCCESS) | ||
} | ||
} |