Skip to content

Commit

Permalink
[chore] Ignore unit test regarding compiler options for Java verisons…
Browse files Browse the repository at this point in the history
… > 17
  • Loading branch information
Tobias Stamann committed Mar 21, 2024
1 parent 424e3de commit 5dd2c38
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions cute/src/test/java/io/toolisticon/cute/CuteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void test_UnitTest_successfulCompilation_build() {
}

@Test
public void test_compilationWithCompilerOptions_happyPath (){
public void test_compilationWithCompilerOptions_happyPath() {
Cute.blackBoxTest().given().noProcessors()
.andSourceFiles("/compiletests/compileroptionstest/Java8Code.java")
.andUseCompilerOptions("-source 1.8", "-target 1.8")
Expand All @@ -87,25 +87,40 @@ public void test_compilationWithCompilerOptions_happyPath (){
}

@Test
public void test_compilationWithCompilerOptions_invalidUsageOfJava8Code (){
Cute.blackBoxTest().given().noProcessors()
.andSourceFiles("/compiletests/compileroptionstest/Java8Code.java")
.andUseCompilerOptions("-source 1.7", "-target 1.7")
.whenCompiled().thenExpectThat().compilationFails()
.andThat().compilerMessage().ofKindError().atSource("/compiletests/compileroptionstest/Java8Code.java").atLine(10).atColumn(56).contains("lambda expressions are not supported")
.andThat().generatedClass("io.toolisticon.cute.testcases.Java8Code").doesntExist()
.executeTest();
public void test_compilationWithCompilerOptions_invalidUsageOfJava8Code() {
if (getJavaVersion() <= 17) {
Cute.blackBoxTest().given().noProcessors()
.andSourceFiles("/compiletests/compileroptionstest/Java8Code.java")
.andUseCompilerOptions("-source 1.7", "-target 1.7")
.whenCompiled().thenExpectThat().compilationFails()
.andThat().compilerMessage().ofKindError().atSource("/compiletests/compileroptionstest/Java8Code.java").atLine(10).atColumn(56).contains("lambda expressions are not supported")
.andThat().generatedClass("io.toolisticon.cute.testcases.Java8Code").doesntExist()
.executeTest();
}
}


private static int getJavaVersion() {
String version = System.getProperty("java.version");
if (version.startsWith("1.")) {
version = version.substring(2, 3);
} else {
int dot = version.indexOf(".");
if (dot != -1) {
version = version.substring(0, dot);
}
}
return Integer.parseInt(version);
}

@Test
public void test_addSourceFromString(){
Cute.blackBoxTest().given()
.noProcessors()
.andSourceFile("io.toolisticon.cute.Testclass","package io.toolisticon.cute; public class Testclass{}")
.whenCompiled().thenExpectThat().compilationSucceeds()
.andThat().generatedClass("io.toolisticon.cute.Testclass").exists()
.executeTest();
public void test_addSourceFromString() {
Cute.blackBoxTest().given()
.noProcessors()
.andSourceFile("io.toolisticon.cute.Testclass", "package io.toolisticon.cute; public class Testclass{}")
.whenCompiled().thenExpectThat().compilationSucceeds()
.andThat().generatedClass("io.toolisticon.cute.Testclass").exists()
.executeTest();
}


Expand Down

0 comments on commit 5dd2c38

Please sign in to comment.