Skip to content

Commit 990985c

Browse files
author
Tobias Stamann
committed
Merge branch 'develop'
2 parents d79ceaa + 85914ca commit 990985c

File tree

25 files changed

+96
-23
lines changed

25 files changed

+96
-23
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,37 @@ public void yourUnitTestWithPassedInElementAndProcessor() {
224224

225225
}
226226
```
227-
227+
228+
### Testing generated and compiled classes
229+
Testing of the generated code can either be done by providing an integration test project or by using Cute as part of the compilation test.
230+
Unfortunately, testing generated code with Cute heavily relies on the Javas reflection api, since generated classes aren't available in your unit test code.
231+
But it's working flawlessly if your generated classes are implementing precompiled interfaces:
232+
233+
````java
234+
@Test
235+
public void blackBoxTest_justCompileCodeAndDoClassTestWithImplementedInterface() {
236+
Cute.blackBoxTest().given().noProcessors()
237+
.andSourceFiles("/TestClassWithImplementedInterface.java")
238+
.whenCompiled()
239+
.thenExpectThat()
240+
.compilationSucceeds()
241+
.andThat()
242+
.generatedClass("io.toolisticon.cute.TestClassWithImplementedInterface")
243+
.testedSuccessfullyBy(new GeneratedClassesTestForSpecificClass() {
244+
@Override
245+
public void doTests(Class<?> clazz, CuteClassLoader cuteClassLoader) throws Exception{
246+
247+
SimpleTestInterface unit = (SimpleTestInterface) clazz.getConstructor().newInstance();
248+
MatcherAssert.assertThat(unit.saySomething(), Matchers.is("WHATS UP?"));
249+
250+
}
251+
})
252+
.executeTest();
253+
}
254+
````
255+
256+
Consider to prefer integration tests over Cute if no precompiled interface is implemented by the generated classes.
257+
228258
# Projects using this toolkit library
229259

230260
- [Annotation processor toolkit](https://github.com/toolisticon/annotation-processor-toolkit) : Toolkit that allows you to build annotation processors in a more comfortable way

coverage/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>io.toolisticon.cute</groupId>
1010
<artifactId>cute-parent</artifactId>
11-
<version>1.0.0_RC2</version>
11+
<version>1.0.0</version>
1212
</parent>
1313

1414
<name>coverage</name>

cute/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>io.toolisticon.cute</groupId>
99
<artifactId>cute-parent</artifactId>
10-
<version>1.0.0_RC2</version>
10+
<version>1.0.0</version>
1111
</parent>
1212

1313
<name>cute</name>

cute/src/main/java/io/toolisticon/cute/CuteApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ public interface CompilerTestExpectThatInterface {
872872
* @param generatedClassesTest the test to execute
873873
* @return the next interface
874874
*/
875-
CompilerTestExpectAndThatInterface compiledClassesTestsSucceeds(@FluentApiBackingBeanMapping(value = "generatedClassesTest", action = MappingAction.ADD) GeneratedClassesTest generatedClassesTest);
875+
CompilerTestExpectAndThatInterface generatedClassesTestedSuccessfullyBy(@FluentApiBackingBeanMapping(value = "generatedClassesTest", action = MappingAction.ADD) GeneratedClassesTest generatedClassesTest);
876876

877877

878878
/**

cute/src/test/java/io/toolisticon/cute/CuteTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ public void blackBoxTest_justCompileCodeAndDoClassTest3() {
10251025
.whenCompiled()
10261026
.thenExpectThat()
10271027
.compilationSucceeds()
1028-
.andThat().compiledClassesTestsSucceeds(new GeneratedClassesTest() {
1028+
.andThat().generatedClassesTestedSuccessfullyBy(new GeneratedClassesTest() {
10291029
@Override
10301030
public void doTests(CuteClassLoader cuteClassLoader) throws Exception{
10311031
Class<?> clazz = cuteClassLoader.getClass("io.toolisticon.cute.TestClassWithInnerClasses");
@@ -1086,4 +1086,23 @@ public void doTests(Class<?> clazz, CuteClassLoader cuteClassLoader) throws Exce
10861086
.executeTest();
10871087
}
10881088

1089+
1090+
@Test()
1091+
public void blackBoxTest_justCompileCodeAndDoClassTestWithImplementedInterfaceAndRelationsBetweenClasses() {
1092+
Cute.blackBoxTest().given().noProcessors()
1093+
.andSourceFiles("/compiletests/withmultiplerelatedsourcefiles/JustOutput.java", "/compiletests/withmultiplerelatedsourcefiles/TestClassWithImplementedInterface.java")
1094+
.whenCompiled()
1095+
.thenExpectThat()
1096+
.compilationSucceeds()
1097+
.andThat().generatedClass("io.toolisticon.cute.TestClassWithImplementedInterface").testedSuccessfullyBy(new GeneratedClassesTestForSpecificClass() {
1098+
@Override
1099+
public void doTests(Class<?> clazz, CuteClassLoader cuteClassLoader) throws Exception{
1100+
1101+
SimpleTestInterface unit = (SimpleTestInterface) clazz.getConstructor().newInstance();
1102+
MatcherAssert.assertThat(unit.saySomething(), Matchers.is("WHATS UP???"));
1103+
1104+
}
1105+
})
1106+
.executeTest();
1107+
}
10891108
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package io.toolisticon.cute;
2+
3+
public class JustOutput {
4+
5+
public static String getString() {
6+
return "WHATS UP???";
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.toolisticon.cute;
2+
3+
import io.toolisticon.cute.TestAnnotation;
4+
import io.toolisticon.cute.testcases.SimpleTestInterface;
5+
6+
/**
7+
* Test class for annotation processor tools.
8+
*/
9+
@TestAnnotation
10+
public class TestClassWithImplementedInterface implements SimpleTestInterface {
11+
12+
@Override
13+
public String saySomething() {
14+
return JustOutput.getString();
15+
}
16+
}

extension/api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>io.toolisticon.cute</groupId>
99
<artifactId>extension-parent</artifactId>
10-
<version>1.0.0_RC2</version>
10+
<version>1.0.0</version>
1111
</parent>
1212

1313
<name>extension-api</name>

extension/junit4/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>io.toolisticon.cute</groupId>
1010
<artifactId>extension-parent</artifactId>
11-
<version>1.0.0_RC2</version>
11+
<version>1.0.0</version>
1212
</parent>
1313

1414
<name>extension-junit4</name>

extension/junit5/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>io.toolisticon.cute</groupId>
1010
<artifactId>extension-parent</artifactId>
11-
<version>1.0.0_RC2</version>
11+
<version>1.0.0</version>
1212
</parent>
1313

1414
<name>extension-junit5</name>

extension/modulesupport/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>io.toolisticon.cute</groupId>
99
<artifactId>extension-parent</artifactId>
10-
<version>1.0.0_RC2</version>
10+
<version>1.0.0</version>
1111
</parent>
1212

1313
<name>extension-modulesupport</name>

extension/plainjava/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>io.toolisticon.cute</groupId>
1010
<artifactId>extension-parent</artifactId>
11-
<version>1.0.0_RC2</version>
11+
<version>1.0.0</version>
1212
</parent>
1313

1414
<name>extension-plainjava</name>

extension/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>io.toolisticon.cute</groupId>
99
<artifactId>cute-parent</artifactId>
10-
<version>1.0.0_RC2</version>
10+
<version>1.0.0</version>
1111
</parent>
1212

1313
<name>extension-parent</name>

extension/testng/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>io.toolisticon.cute</groupId>
99
<artifactId>extension-parent</artifactId>
10-
<version>1.0.0_RC2</version>
10+
<version>1.0.0</version>
1111
</parent>
1212

1313
<name>extension-testng</name>

integration-test/java9/namedAutomaticModule/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>io.toolisticon.cute</groupId>
1010
<artifactId>integration-test-java9-parent</artifactId>
11-
<version>1.0.0_RC2</version>
11+
<version>1.0.0</version>
1212
</parent>
1313

1414
<name>integration-test-java9-namedAutomaticModule</name>

integration-test/java9/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>io.toolisticon.cute</groupId>
1010
<artifactId>integration-test-parent</artifactId>
11-
<version>1.0.0_RC2</version>
11+
<version>1.0.0</version>
1212
</parent>
1313

1414
<name>integration-test-java9-parent</name>

integration-test/java9/regularTestModule/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>io.toolisticon.cute</groupId>
1010
<artifactId>integration-test-java9-parent</artifactId>
11-
<version>1.0.0_RC2</version>
11+
<version>1.0.0</version>
1212
</parent>
1313

1414
<name>integration-test-java9-regularModule</name>

integration-test/java9/test/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>io.toolisticon.cute</groupId>
1010
<artifactId>integration-test-java9-parent</artifactId>
11-
<version>1.0.0_RC2</version>
11+
<version>1.0.0</version>
1212
</parent>
1313

1414
<name>integration-test-java9-test</name>

integration-test/java9/unnamedAutomaticModule/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>io.toolisticon.cute</groupId>
1010
<artifactId>integration-test-java9-parent</artifactId>
11-
<version>1.0.0_RC2</version>
11+
<version>1.0.0</version>
1212
</parent>
1313

1414
<name>integration-test-java9-unnamedAutomaticModule</name>

integration-test/junit4/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>io.toolisticon.cute</groupId>
1010
<artifactId>integration-test-parent</artifactId>
11-
<version>1.0.0_RC2</version>
11+
<version>1.0.0</version>
1212
</parent>
1313

1414
<name>integration-test-junit4</name>

integration-test/junit5/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>io.toolisticon.cute</groupId>
1010
<artifactId>integration-test-parent</artifactId>
11-
<version>1.0.0_RC2</version>
11+
<version>1.0.0</version>
1212
</parent>
1313

1414
<name>integration-test-junit5</name>

integration-test/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>io.toolisticon.cute</groupId>
99
<artifactId>cute-parent</artifactId>
10-
<version>1.0.0_RC2</version>
10+
<version>1.0.0</version>
1111
</parent>
1212

1313
<name>integration-test-parent</name>

integration-test/testng/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>io.toolisticon.cute</groupId>
99
<artifactId>integration-test-parent</artifactId>
10-
<version>1.0.0_RC2</version>
10+
<version>1.0.0</version>
1111
</parent>
1212

1313
<name>integration-test-testng</name>

legacy/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>io.toolisticon.cute</groupId>
1010
<artifactId>cute-parent</artifactId>
11-
<version>1.0.0_RC2</version>
11+
<version>1.0.0</version>
1212
</parent>
1313

1414
<name>cute-legacy</name>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>io.toolisticon.cute</groupId>
66
<artifactId>cute-parent</artifactId>
7-
<version>1.0.0_RC2</version>
7+
<version>1.0.0</version>
88
<packaging>pom</packaging>
99

1010
<name>cute-parent</name>

0 commit comments

Comments
 (0)