Skip to content

How to include/exclude tests given a list of test cases #4121

Answered by marcphilipp
mumrah asked this question in Q&A
Discussion options

You must be logged in to vote

You can implement a PostDiscoveryFilter (and register it via ServiceLoader) that inspect the TestSource of each TestDescriptor and exclude it if it's a MethodSource for one of the methods in your file.

Something like this should work:

import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

import org.junit.platform.engine.FilterResult;
import org.junit.platform.engine.TestDescriptor;
import org.junit.platform.engine.support.descriptor.MethodSource;

public class ExcludedMethodsFromFileFilter implements PostDiscoveryFilter {

	private final List<String> exclusions;

	public ExcludedMethodsFromFileFilter(…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mumrah
Comment options

Answer selected by mumrah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants