XharnessTask xhTask = new XharnessTask();
xhTask.setName("bar");
xhTask.setPattern("spam");
xhTask.setProject(project);
xhTask.setResultsdir(resultsDir);
TaskRegistry registry = null;
try {
registry = TaskRegistry.init(xhTask);
TestCaseTask test = new TestCaseTask();
test.setProject(project);
test.setName("foo");
TestLogger logger = new TestLogger(registry, test, "foo", registry.getCurrentTest());
registry.setCurrentTest(logger);
MockControl ctrl = MockClassControl.createControl(Task.class);
Task mock = (Task)ctrl.getMock();
ctrl.replay();
test.addTask(mock);
try {
test.execute();
fail("Expected TestSkippedException");
} catch (TestSkippedException tse) {
assertEquals("Wrong message",
"testcase foo doesn't match pattern. Skipped.",
tse.getMessage());
}
ctrl.verify();
} finally {
if (registry != null) {
registry.shutdown(null);
}
TempDir.removeFiles(resultsDir);
}
}