Skip to content

Add support for test engine jqwik#3298

Closed
gtrefs wants to merge 45 commits intotestcontainers:masterfrom
gtrefs:testengine/jqwik
Closed

Add support for test engine jqwik#3298
gtrefs wants to merge 45 commits intotestcontainers:masterfrom
gtrefs:testengine/jqwik

Conversation

@gtrefs
Copy link

@gtrefs gtrefs commented Oct 3, 2020

This pull request adds support for the property-based testing engine jqwik. jqwik is a junit platform test engine. Lifecycle Hooks in Jqwik are still experimental. I will ask Johannes Link to have a look at this PR. Maybe he has some additions.

  • The module should use as few dependencies as possible,

    • The module has jqwik as single compile time dependency, apart from the testconainers project.
  • Regarding libraries, either:

    • they should be compileOnly if they are likely to already be on the classpath for users' tests (e.g. client libraries or drivers)
    • they can be implementation (and thus transitive dependencies) if they are very unlikely to conflict with users' dependencies.
  • If client libraries are used to test or use the module, these MUST be legal for Testcontainers developers and Testcontainers users to download and use.

    • Jqwik uses the Eclipse Public License - v 2.0
  • Every module MUST have a dedicated documentation page containing:

    • A high level overview
    • A usage example
    • If appropriate, basic API documentation or further usage guidelines
    • Dependency information
    • Acknowledgements, if appropriate
      • I borrowed some code from Jupiter extension. Should I acknowledge this?
  • Consider that many users will not read the documentation pages - even if the first person to add it to a project does, people reading/updating the code in the future may not. Try and avoid the need for critical knowledge that is only present in documentation.

    • Annotations are similar to the ones of the Jupiter extension

gtrefs added 30 commits October 3, 2020 12:36
The TestContainersExtension of Jupiter was adapted to support the BeforeContainer, AfterContainer and AroundProperty hooks. They work in the same way as the Jupiter pendants. However, the Container annotation was renamed to TestContainer because the name container is already used in Jqwik for any class which contains properties.

Further, the store in Jqwik is not bound to its current context and not a key-value store. Though, it can be scoped to the overall run, property or the current try.
Converted parameterized test into a property.
Converted test from Jupiter to Jqwik
A PropertyLifecyclyeContext does not provide the means to access the parent instance.
This makes it hard to access the parent test instance. The nested container is started
and stopped. Different to Jupiter, Jqwik traverses the tree of test elements bottom-up
and first runs the properties within a group.
Shared containers are available in a group.
Containers in groups are started and stopped.
If a container is lifecycle aware, it is handed over the exception, if there was one after property execution.
In order to better align with the Jupiter extensions, the TestContainer annotation was renamed again to Container.
Stores in Jqwik don't close entries of any kind. Similar functionality is achieved by using the onClose callback.
The runtime databse stores data of the previous engine run. Thus, the file should not be stored in git.
Started documentation of the jqwik lifecycle hook.
@gtrefs
Copy link
Author

gtrefs commented Oct 5, 2020

I talked to Johannes. I am going to add the AroundPropertyHook, so that containers are restarted after each try.

gtrefs added 3 commits October 6, 2020 22:40
A Container annotation now supports a flag called restartPerTry which causes containers to be started before each try and stopped after a try. LifeCycleAware containers are not yet supported.
@gtrefs
Copy link
Author

gtrefs commented Oct 6, 2020

I added support for restart after each try

@gtrefs
Copy link
Author

gtrefs commented Oct 7, 2020

The build is failing because of a 503. Tests are passing @kiview @bsideup @rnorth

@rnorth
Copy link
Member

rnorth commented Oct 9, 2020

Sorry for not commenting sooner - as you can see we're quite underwater with the number of PRs at the moment, and we're focused on the urgent issue of Docker Hub rate limiting coming up.

We saw jqwik-team/jqwik-testcontainers#1 and we think that's a good approach for everybody. Kotest did similarly.

@gtrefs
Copy link
Author

gtrefs commented Oct 16, 2020

@rnorth I pushed the code to https://github.com/jlink/jqwik-testcontainers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants