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

Discussion: Offensively communicate assumption like extensions #817

Open
Bukama opened this issue Apr 20, 2024 · 0 comments
Open

Discussion: Offensively communicate assumption like extensions #817

Bukama opened this issue Apr 20, 2024 · 0 comments

Comments

@Bukama
Copy link
Member

Bukama commented Apr 20, 2024

In #550 we've (discussed and) decided to provide extensions which act like assumptions.

Examples for such extensions are

One argument to provide such was that they allow the user to move assumption code to an annotation and therefore increase readability of the exact test code.
One argument against was that its architecturally "wrong" [this comment by @Michael1993] (see #550 (comment)).

This issue is NOT to reopen that discussion but to discuss

  • about making such extensions and the underlying decision more visible in our documentation
  • maybe introduce code changes, e.g. an abstract AssumptionExtension which handles things all of those the same

Some pseudo code idea


public abstract class AssumptionExtension implements ExecutionCondition  {

	@Override
	public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
		var optAnnotation = findClosestEnclosingAnnotation(context, AssumptionExtensionAnnotation.class);

		if (optAnnotation.isEmpty()) {
			return enabled("No AssumptionExtensionAnnotation annotation found.");
		}

		DisabledIfNotReachableConfiguration shallWeDoSomething = decideToDisableOrFail(context, optAnnotation.get());
	}

  protected abstract DisabledIfNotReachableConfiguration decideToDisableOrFail(ExtensionContext context, AssumptionExtensionAnnotation annotation);

}


public ConcreteExtension extends AssumptionExtension {

  @Override
  DisabledIfNotReachableConfiguration decideToDisableOrFail(ExtensionContext context, AssumptionExtensionAnnotation annotation) {

    // Errors
    throw new ExtensionConfigurationException("Something went wront, fail the test");

    // Disable or not
    if (enable) {
			return enabled(format("%s is enabled because XXXX", context.getUniqueId()));
		} else {
			return disabled(format("%s is disenabled because XXXX", context.getUniqueId()));
		}
  }
}


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

1 participant