Skip to content

Commit

Permalink
Fixed integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Stamann committed Jan 19, 2024
1 parent 00db7c8 commit 2ced54d
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 51 deletions.
1 change: 1 addition & 0 deletions cute/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
</excludes>
<includes>
<include>io.toolisticon.cute:*</include>
<include>io.toolisticon.fluapigen:fluapigen-api:compile:*</include>
<include>*:*:*:*:test:*</include>
<include>*:*:*:*:provided:*</include>
</includes>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package io.toolisticon.cute.integrationtest.junit4;


import io.toolisticon.cute.UnitTest;
import io.toolisticon.cute.Cute;
import io.toolisticon.cute.UnitTestWithoutPassIn;
import io.toolisticon.cute.extension.api.AssertionSpiServiceLocator;
import io.toolisticon.cute.extension.junit4.JUnit4Assertion;
import org.hamcrest.MatcherAssert;
Expand All @@ -10,7 +11,6 @@
import org.junit.Test;

import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
import javax.tools.Diagnostic;

/**
Expand All @@ -28,16 +28,17 @@ public void testServiceLocator() {
@Test
public void warningMessageTest() {

CompileTestBuilder
Cute
.unitTest()
.defineTest(new UnitTest<Element>() {
.when(new UnitTestWithoutPassIn() {
@Override
public void unitTest(ProcessingEnvironment processingEnvironment, Element typeElement) {
public void unitTest(ProcessingEnvironment processingEnvironment) {
processingEnvironment.getMessager().printMessage(Diagnostic.Kind.WARNING, "WARNING!");
}
})
.expectWarningMessageThatContains("WARNING!")
.compilationShouldSucceed()
.thenExpectThat()
.compilationSucceeds()
.andThat().compilerMessage().ofKindWarning().contains("WARNING!")
.executeTest();


Expand All @@ -46,16 +47,17 @@ public void unitTest(ProcessingEnvironment processingEnvironment, Element typeEl
@Test
public void successfullFailingCompilationTest_ByErrorMessage() {

CompileTestBuilder
Cute
.unitTest()
.defineTest(new UnitTest<Element>() {
.when(new UnitTestWithoutPassIn() {
@Override
public void unitTest(ProcessingEnvironment processingEnvironment, Element element) {
public void unitTest(ProcessingEnvironment processingEnvironment) {
processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR, "ERROR!");
}
})
.expectErrorMessageThatContains("ERROR!")
.compilationShouldFail()
.thenExpectThat()
.compilationFails()
.andThat().compilerMessage().ofKindError().contains("ERROR!")
.executeTest();


Expand All @@ -65,15 +67,16 @@ public void unitTest(ProcessingEnvironment processingEnvironment, Element elemen
public void failingCompilationTest_ByErrorMessage() {

try {
CompileTestBuilder
Cute
.unitTest()
.defineTest(new UnitTest<Element>() {
.when(new UnitTestWithoutPassIn() {
@Override
public void unitTest(ProcessingEnvironment processingEnvironment, Element typeElement) {
public void unitTest(ProcessingEnvironment processingEnvironment) {
processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR, "ERROR!");
}
})
.compilationShouldSucceed()
.thenExpectThat()
.compilationSucceeds()
.executeTest();

Assert.fail("Should have failed");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package io.toolisticon.cute.integrationtest.junit5;


import io.toolisticon.cute.UnitTest;
import io.toolisticon.cute.Cute;
import io.toolisticon.cute.UnitTestWithoutPassIn;
import io.toolisticon.cute.extension.api.AssertionSpiServiceLocator;
import io.toolisticon.cute.extension.junit5.JUnit5Assertion;
import org.hamcrest.MatcherAssert;
Expand All @@ -10,7 +11,6 @@
import org.junit.jupiter.api.Test;

import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
import javax.tools.Diagnostic;

/**
Expand All @@ -28,34 +28,36 @@ public void testServiceLocator() {
@Test
public void warningMessageTest() {

CompileTestBuilder
Cute
.unitTest()
.defineTest(new UnitTest<Element>() {
.when(new UnitTestWithoutPassIn() {
@Override
public void unitTest(ProcessingEnvironment processingEnvironment, Element element) {
public void unitTest(ProcessingEnvironment processingEnvironment) {
processingEnvironment.getMessager().printMessage(Diagnostic.Kind.WARNING, "WARNING!");
}
})
.expectWarningMessageThatContains("WARNING!")
.compilationShouldSucceed()
.thenExpectThat()
.compilationSucceeds()
.andThat().compilerMessage().ofKindWarning().contains("WARNING!")
.executeTest();


}

@Test
public void successfullFailingCompilationTest_ByErrorMessage() {
public void successfulFailingCompilationTest_ByErrorMessage() {

CompileTestBuilder
Cute
.unitTest()
.defineTest(new UnitTest<Element>() {
.when(new UnitTestWithoutPassIn() {
@Override
public void unitTest(ProcessingEnvironment processingEnvironment, Element element) {
public void unitTest(ProcessingEnvironment processingEnvironment) {
processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR, "ERROR!");
}
})
.expectErrorMessageThatContains("ERROR!")
.compilationShouldFail()
.thenExpectThat()
.compilationFails()
.andThat().compilerMessage().ofKindError().contains("ERROR!")
.executeTest();


Expand All @@ -65,20 +67,20 @@ public void unitTest(ProcessingEnvironment processingEnvironment, Element elemen
public void failingCompilationTest_ByErrorMessage() {

try {
CompileTestBuilder
Cute
.unitTest()
.defineTest(new UnitTest<Element>() {
.when(new UnitTestWithoutPassIn() {
@Override
public void unitTest(ProcessingEnvironment processingEnvironment, Element element) {
public void unitTest(ProcessingEnvironment processingEnvironment) {
processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR, "ERROR!");
}
})
.compilationShouldSucceed()
.thenExpectThat().compilationSucceeds()
.executeTest();

Assertions.fail("Should have failed");
} catch (AssertionError error) {
Assertions.assertEquals(error.getMessage(), "Compilation should have succeeded but failed");
Assertions.assertTrue(error.getMessage().startsWith("Compilation should have succeeded but failed"));
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.toolisticon.cute.integrationtest.testng;

import io.toolisticon.cute.Cute;
import io.toolisticon.cute.UnitTest;
import io.toolisticon.cute.UnitTestWithoutPassIn;
import io.toolisticon.cute.extension.api.AssertionSpiServiceLocator;
import io.toolisticon.cute.extension.testng.TestNGAssertion;
import org.hamcrest.MatcherAssert;
Expand All @@ -27,17 +29,17 @@ public void testServiceLocator() {
@Test
public void warningMessageTest() {

CompileTestBuilder

Cute
.unitTest()
.defineTest(new UnitTest<Element>() {
.when(new UnitTestWithoutPassIn() {
@Override
public void unitTest(ProcessingEnvironment processingEnvironment, Element typeElement) {
public void unitTest(ProcessingEnvironment processingEnvironment) {
processingEnvironment.getMessager().printMessage(Diagnostic.Kind.WARNING, "WARNING!");
}
})
.expectWarningMessageThatContains("WARNING!")
.compilationShouldSucceed()
.thenExpectThat()
.compilationSucceeds()
.andThat().compilerMessage().ofKindWarning().contains("WARNING!")
.executeTest();


Expand All @@ -46,16 +48,16 @@ public void unitTest(ProcessingEnvironment processingEnvironment, Element typeEl
@Test
public void successfullFailingCompilationTest_ByErrorMessage() {

CompileTestBuilder
Cute
.unitTest()
.defineTest(new UnitTest<Element>() {
.when(new UnitTestWithoutPassIn() {
@Override
public void unitTest(ProcessingEnvironment processingEnvironment, Element element) {
public void unitTest(ProcessingEnvironment processingEnvironment) {
processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR, "ERROR!");
}
})
.expectErrorMessageThatContains("ERROR!")
.compilationShouldFail()
.thenExpectThat().compilationFails()
.andThat().compilerMessage().ofKindError().contains("ERROR!")
.executeTest();


Expand All @@ -65,15 +67,15 @@ public void unitTest(ProcessingEnvironment processingEnvironment, Element elemen
public void failingCompilationTest_ByErrorMessage() {

try {
CompileTestBuilder
Cute
.unitTest()
.defineTest(new UnitTest<Element>() {
.when(new UnitTestWithoutPassIn() {
@Override
public void unitTest(ProcessingEnvironment processingEnvironment, Element element) {
public void unitTest(ProcessingEnvironment processingEnvironment) {
processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR, "ERROR!");
}
})
.compilationShouldSucceed()
.thenExpectThat().compilationSucceeds()
.executeTest();

Assert.fail("Should have failed");
Expand Down
1 change: 0 additions & 1 deletion legacy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<dependency>
<groupId>io.toolisticon.fluapigen</groupId>
<artifactId>fluapigen-api</artifactId>
<scope>compile</scope>
</dependency>

<!-- Test dependencies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,9 @@ static void myCommand(CuteApi.CompilerTestBB backingBean) {
if (backingBean.testType() == CuteApi.TestType.UNIT && backingBean.sourceFiles().size() == 0) {
backingBean.sourceFiles().add(JavaFileObjectUtils.readFromResource("/AnnotationProcessorUnitTestClass.java"));
}
if (backingBean.testType() == CuteApi.TestType.BLACK_BOX && backingBean.sourceFiles().size() == 0) {
throw new IllegalStateException("There must be at least one source file present to execute a black box test!");
}
new CompileTest(backingBean).executeTest();
}
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@
<groupId>io.toolisticon.fluapigen</groupId>
<artifactId>fluapigen-api</artifactId>
<version>${fluapigen.version}</version>
<scope>provided</scope>
<scope>compile</scope>
</dependency>


Expand Down

0 comments on commit 2ced54d

Please sign in to comment.