Skip to content

0.8.x Annotations for JUnit4 @ConfigureWith

Hiroshi Ukai edited this page Sep 17, 2017 · 8 revisions

You can control how test suite is generated using this annotation.

  @ConfigureWith(
    parameterSpace = Example.class
  )

With this annotation you can define requirements for test suite to be generated and a parameter space, from which the test suite to be generated.

Feature Specification
name @ConfigureWith
package com.github.dakusui.jcunit8.runners.junit4.annotations
target A test class
attributes value, parameterSpace

Attributes

value

With this attribute you can specify characteristics a test suite to be generated. You can give to this attribute a class that extends com.github.dakusui.jcunit8.pipeline.stages.ConfigFactory, that requires you to let JCUnit know "strength", "seeds", and if "negative tests" is required or not.

By default, ConfigFactory.Default is used. This makes JCUnit generate a test suite whose strength is 2, with no seed, and has no negative test.

@ConfigureWith(QuadraticEquationExampleWithSeeds.Config.class)
public class QuadraticEquationExampleWithSeeds extends QuadraticEquationExample {
  public static class Config extends ConfigFactory.Base {
    @Override
    protected Requirement defineRequirement(Requirement.Builder defaultValues) {
      return defaultValues.withNegativeTestGeneration(
          true
      ).addSeed(
          // Positive test
          Tuple.builder().put("a", 1).put("b", -2).put("c", 1).build()
      ).addSeed(
          // Negative test
          Tuple.builder().put("a", 1).put("b", 1).put("c", 1).build()
      ).build();
    }
  }
}

parameterSpace

With this attribute you can choose a class that defines a parameter space. A parameter space consists of a set of parameters and a set of constraints for them. From it JCUnit generates a test suite.

By default, the same class the this annotation is attached to is used.

Clone this wiki locally