use of org.junit.runner.manipulation.NoTestsRemainException in project junit4 by junit-team.
the class ParentRunnerFilteringTest method testSuiteFiltering.
@Test
public void testSuiteFiltering() throws Exception {
Runner runner = Request.aClass(ExampleSuite.class).getRunner();
Filter filter = notThisMethodName("test1");
try {
filter.apply(runner);
} catch (NoTestsRemainException e) {
return;
}
fail("Expected 'NoTestsRemainException' due to complete filtering");
}
use of org.junit.runner.manipulation.NoTestsRemainException in project junit4 by junit-team.
the class ParentRunnerFilteringTest method testSuiteFilteringWithUnmodifyableChildList.
@Test
public void testSuiteFilteringWithUnmodifyableChildList() throws Exception {
Runner runner = Request.aClass(ExampleSuiteWithUnmodifyableChildList.class).getRunner();
Filter filter = notThisMethodName("test1");
try {
filter.apply(runner);
} catch (NoTestsRemainException e) {
return;
}
fail("Expected 'NoTestsRemainException' due to complete filtering");
}
use of org.junit.runner.manipulation.NoTestsRemainException in project junit4 by junit-team.
the class FilterRequest method getRunner.
@Override
public Runner getRunner() {
try {
Runner runner = request.getRunner();
fFilter.apply(runner);
return runner;
} catch (NoTestsRemainException e) {
return new ErrorReportingRunner(Filter.class, new Exception(String.format("No tests found matching %s from %s", fFilter.describe(), request.toString())));
}
}
use of org.junit.runner.manipulation.NoTestsRemainException in project junit4 by junit-team.
the class JUnit38ClassRunner method filter.
public void filter(Filter filter) throws NoTestsRemainException {
if (getTest() instanceof Filterable) {
Filterable adapter = (Filterable) getTest();
adapter.filter(filter);
} else if (getTest() instanceof TestSuite) {
TestSuite suite = (TestSuite) getTest();
TestSuite filtered = new TestSuite(suite.getName());
int n = suite.testCount();
for (int i = 0; i < n; i++) {
Test test = suite.testAt(i);
if (filter.shouldRun(makeDescription(test))) {
filtered.addTest(test);
}
}
setTest(filtered);
if (filtered.testCount() == 0) {
throw new NoTestsRemainException();
}
}
}
use of org.junit.runner.manipulation.NoTestsRemainException in project pinpoint by naver.
the class PinpointPluginTestRunner method filter.
@Override
public void filter(Filter filter) throws NoTestsRemainException {
synchronized (childrenLock) {
List<FrameworkMethod> children = new ArrayList<FrameworkMethod>(getFilteredChildren());
for (Iterator<FrameworkMethod> iter = children.iterator(); iter.hasNext(); ) {
FrameworkMethod each = iter.next();
if (shouldRun(filter, each)) {
try {
filter.apply(each);
} catch (NoTestsRemainException e) {
iter.remove();
}
} else {
iter.remove();
}
}
filteredChildren = Collections.unmodifiableCollection(children);
if (filteredChildren.isEmpty()) {
throw new NoTestsRemainException();
}
}
}
Aggregations