Skip to content
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

Replace jqwik.properties with JUnit Platform Mechanism for Configuration #139

Closed
jlink opened this issue Dec 9, 2020 · 9 comments
Closed

Comments

@jlink
Copy link
Collaborator

jlink commented Dec 9, 2020

Testing Problem

jqwik has its own way to configure itself: jqwik.properties. This has a couple of disadvantages:

  • Users must be taught how to use it
  • Users must create such a file in each of their projects
  • There's currently no mechanism to override configuration parameters, e.g. through system properties or runtime parameters

Suggested Solution

Switch to the configuration mechanism built into the JUnit platform.

For versions 1.4.x the old mechanism must be kept for backwards compatibility.

The first implementation step should cover:

  • Configuration properties can be loaded from jqwik.properties or from junit-platform.properties with an additional "jqwik." prefix
  • Loading from jqwik.properties will log a WARNING
  • Having a parameter in both file will log an ERROR. Parameter from junit-platform.properties has precedence
  • Rename some of the config parameters for junit-platform.properties (log an ERROR if old name is used there)
    • defaultTries -> jqwik.tries.default
    • defaultMaxDiscardRatio -> jqwik.maxDiscardRatio.default
    • defaultGeneration -> jqwik.generation.default
    • defaultAfterFailure -> jqwik.afterFailure.default
    • defaultEdgeCases -> jqwik.edgeCases.default
    • defaultShrinking -> jqwik.shrinking.default
  • Optional: Provide a tool to translate jqwik.properties into junit-platform.properties

Discussion

  • Currently jqwik gets its configuration when creating the instance of JqwikTestEngine.
    The ConfigurationParameters instance is only available in discovery and execution requests.
    Maybe a first step should move the retrieval of JqwikConfiguration into the request methods to
    facilitate migration.

  • JUnit's ConfigurationParameters interface does not provide a means to get all parameters with a certain prefix.
    That means that it will no longer be possible to warn about unused/unknown parameters (e.g. through spelling errors).

  • Should camel case names be replaced by names with hyphens or underscores?

@osi
Copy link
Contributor

osi commented Dec 22, 2020

On property naming, the JUnit Jupiter documentation does dot-separated lowercase. they use testinstance and autodetection instead of a camel-cased or adding other separators. a dot appears to be used for grouping (as it does with the proposed .default syntax).

@osi
Copy link
Contributor

osi commented Dec 22, 2020

On the first discussion point, agreed. I was thinking of storing the configuration as a property on JqwikEngineDescriptor, as that descriptor will then be available during execution as the root descriptor.

osi added a commit to osi/jqwik that referenced this issue Dec 22, 2020
  - the is a prereq for jqwik-team#139
  - defer loading of config until test discovery
  - store config as part of the root descriptor
@jlink
Copy link
Collaborator Author

jlink commented Dec 23, 2020

On the first discussion point, agreed. I was thinking of storing the configuration as a property on JqwikEngineDescriptor, as that descriptor will then be available during execution as the root descriptor.

That doesn’t feel right to me because it requires a descriptor to be mutable. Descriptors were designed to be immutable; I think there are places where this is no longer the case but I wouldn’t do it if I can prevent it.

@jlink
Copy link
Collaborator Author

jlink commented Dec 23, 2020

That doesn’t feel right to me because it requires a descriptor to be mutable. Descriptors were designed to be immutable; I think there are places where this is no longer the case but I wouldn’t do it if I can prevent it.

@osi Just had a look at the PR to realise that mutability is NOT required. Your approach looks unusual at first sight (because it stores additional info in the descriptor) but let’s see where it will lead you. It may also be worthwhile to look how Jupiter is doing it.

@osi
Copy link
Contributor

osi commented Dec 25, 2020

jlink pushed a commit that referenced this issue Jan 3, 2021
  - the is a prereq for #139
  - defer loading of config until test discovery
  - store config as part of the root descriptor
@jlink
Copy link
Collaborator Author

jlink commented Jan 3, 2021

The PR has been merged and released in "1.4.0-SNAPSHOT"

@jlink
Copy link
Collaborator Author

jlink commented Jan 3, 2021

@osi There's one minor thing that I couldn't track down quickly: All logging done during configuration loading seems to appear twice when running tests, e.g.

INFORMATION: Loading JUnit Platform configuration parameters from classpath resource [file:/Users/link/Documents/git-projects/jqwik/documentation/out/test/resources/junit-platform.properties].

Is there a straightforward way to prevent duplicate logging? Maybe configuration loading must be lazy and cached?

@osi
Copy link
Contributor

osi commented Jan 4, 2021

I'll take a look.

@jlink
Copy link
Collaborator Author

jlink commented Jan 8, 2021

@osi The double logging comes from JUnit Platform itself, called by IntelliJ. One of the two is the culprit.
I guess we cannot do anything about it. So I close this issue as done.

@jlink jlink closed this as completed Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants