-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove test duplication #255
Conversation
6fc196f
to
dad372a
Compare
Abstract test classes should contain all the test implementations. The other classes that extend this only need to provide the extension. This way we don't have to duplicate all of our test implementations. One thing to note is that injection of the ZeebeClient, ZeebeTestEngine and RecordStream. These fields get injected in what jUnit defines as the test class: final Class<?> requiredTestClass = extensionContext.getRequiredTestClass(); We are dealing with 2 different scenarios. We have the assertion tests. Here the abstract classes contain 2 nested classes, HappyPathTests and UnhappyPathTests. In this scenario the nested class is the test class. These fields get injected just fine. In other tests we do not have any nested classes. Here the class that extends the abstract class will be the test class (e.g. the WorkterTest class). For these classes the fields must be declared on the extending class. We can access these in the abstract class by adding abstract getters.
All unit tests will now extends from an abstract class. This class provides the test implementation. The extending class only needs to have the relevant annotation and in some cases needs to define ZeebeClient, ZeebeTestEngine and RecordStream fields.
The java version in the root pom was 11. This is not accurate as by default we use java 17, unless otherwise specified.
Adds a unit test which will make sure that all the abstract test classes are implemented in the regular and in the testcontainer package, as well as annotated with the correct extension.
In our documentation we talk about the embedded engine. It makes sense to name our packages in a similar way.
Automatically adding the copyright headers included a new line. The maven license plugin does not want this new line, so I have removed this from the configuration.
dad372a
to
6287137
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks clean. One suggestion to make it even cleaner
qa/src/test/java/io/camunda/zeebe/process/test/qa/ExtendAbstractsTest.java
Outdated
Show resolved
Hide resolved
@pihme I've changed the test to use |
199e1ba
to
26ce3f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Looks much better already. Some final suggestions for the cherry on top
qa/src/test/java/io/camunda/zeebe/process/test/qa/ExtendAbstractsTest.java
Outdated
Show resolved
Hide resolved
qa/src/test/java/io/camunda/zeebe/process/test/qa/ExtendAbstractsTest.java
Show resolved
Hide resolved
qa/src/test/java/io/camunda/zeebe/process/test/qa/ExtendAbstractsTest.java
Outdated
Show resolved
Hide resolved
Replace custom implementation with classgraph. This solution is easier to understand.
26ce3f7
to
632b64e
Compare
Description
This PR introduces abstract test classes. Abstract test classes should contain all the test implementations. The other classes that extend this only need to provide the extension. This way we don't have to duplicate all of our test implementations.
One thing to note is that injection of the
ZeebeClient
,ZeebeTestEngine
andRecordStream
. These fields get injected in what jUnit defines as the test class:final Class<?> requiredTestClass = extensionContext.getRequiredTestClass();
We are dealing with 2 different scenarios:
HappyPathTests
andUnhappyPathTests
. In this scenario the nested class is the test class. These fields get injected just fine.WorkterTest
class). For these classes the fields must be declared on the extending class. We can access these in the abstract class by adding abstract getters.Related issues
closes #195
Definition of Done
Not all items need to be done depending on the issue and the pull request.
Code changes:
Testing:
Documentation: