@Override boolean doTestsForClass(Class testClass, @Nullable ClassAnalyser analyser) throws InvocationTargetException { if (gta.isTeamCityLoggingEnabled()) { TeamCityOutputLogger.logSuiteStarted(testClass.getName()); } NameFilter testMethodNameFilter = gta.settings().methodNameFilter(); TestRunner runner = new TestRunner( testClass, testMethodNameFilter, new TestRunner.MethodInvoker() { @Override public boolean invoke(Method method, Object testClassInstance) throws InvocationTargetException, IllegalAccessException { if (method.getReturnType().equals(boolean.class)) { return (Boolean) method.invoke(testClassInstance); } else { // If an exception is thrown, it will be propagated, if not, the test passed. method.invoke(testClassInstance); return true; } } }); // The TestRunner runs the tests and the accountant ticks them off. boolean result = runner.runTestMethods(this, analyser, gta.isTeamCityLoggingEnabled()); if (gta.isTeamCityLoggingEnabled()) { TeamCityOutputLogger.logSuiteFinished(testClass.getName()); } return result; }
@Override PackageInfo productionPackageInfo() { return gta.productionPackagesInfo().packageInfo(packageTested()); }
@Override boolean classIsToBeSkippedBecauseOfSettings(String className) { return gta.classIsToBeSkippedBecauseOfSettings(className); }
@Override boolean continueWithTests(boolean resultSoFar) { return gta.continueWithTests(resultSoFar); }
/** * Creates a <code>CoverageUnitTester</code> that will run unit tests for classes in the parent * package to the package in which this is defined. */ public CoverageUnitTester(@NotNull GrandTestAuto gta) { super(gta.testPackagesInfo().classesRoot()); this.gta = gta; resultsLogger = gta.resultsLogger(); }
@Override void testingError(String str, Exception e) { gta.testingError(str, e); }
public boolean runTest() { ExceptionHandling.classNameToErrorKeyToThrow = new HashMap<String, String>(); testsRun = new LinkedList<String>(); Set<String> expectedTestsRun = new HashSet<String>(); // No restrictionsontests so they all run. expectedTestsRun.add("a44.a.test.UnitTester"); expectedTestsRun.add("a44.b.test.UnitTester"); expectedTestsRun.add("a44.c.test.UnitTester"); expectedTestsRun.add("a44.a.functiontest.FT"); expectedTestsRun.add("a44.b.functiontest.FT"); expectedTestsRun.add("a44.c.functiontest.FT"); expectedTestsRun.add("a44.a.loadtest.LT"); expectedTestsRun.add("a44.b.loadtest.LT"); expectedTestsRun.add("a44.c.loadtest.LT"); GrandTestAuto gta = Helpers.setupForZip(new File(Grandtestauto.test44_zip), true, true, true); assert gta.runAllTests(); // Sanity check. assert testsRun.size() == 9; assert testsRun.containsAll(expectedTestsRun); // Initial package set. expectedTestsRun = new HashSet<String>(); testsRun = new LinkedList<String>(); expectedTestsRun.add("a44.b.test.UnitTester"); expectedTestsRun.add("a44.c.test.UnitTester"); expectedTestsRun.add("a44.b.functiontest.FT"); expectedTestsRun.add("a44.c.functiontest.FT"); expectedTestsRun.add("a44.b.loadtest.LT"); expectedTestsRun.add("a44.c.loadtest.LT"); gta = Helpers.setupForZip( new File(Grandtestauto.test44_zip), true, true, true, "a44.b", null, null, false, false, null, null, null, null, null, null, null, null); assert gta.runAllTests(); // Sanity check. assert testsRun.size() == 6; assert testsRun.containsAll(expectedTestsRun); // Final package set. expectedTestsRun = new HashSet<String>(); testsRun = new LinkedList<String>(); expectedTestsRun.add("a44.a.test.UnitTester"); expectedTestsRun.add("a44.b.test.UnitTester"); expectedTestsRun.add("a44.a.functiontest.FT"); expectedTestsRun.add("a44.b.functiontest.FT"); expectedTestsRun.add("a44.a.loadtest.LT"); expectedTestsRun.add("a44.b.loadtest.LT"); gta = Helpers.setupForZip( new File(Grandtestauto.test44_zip), true, true, true, null, "a44.b.loadtest", null, false, false, null, null, null, null, null, null, null, null); assert gta.runAllTests(); // Sanity check. assert testsRun.size() == 6; assert testsRun.containsAll(expectedTestsRun); // Initial and final package set. expectedTestsRun = new HashSet<String>(); testsRun = new LinkedList<String>(); expectedTestsRun.add("a44.b.test.UnitTester"); expectedTestsRun.add("a44.b.functiontest.FT"); expectedTestsRun.add("a44.b.loadtest.LT"); gta = Helpers.setupForZip( new File(Grandtestauto.test44_zip), true, true, true, "a44.b", "a44.b.loadtest", null, false, false, null, null, null, null, null, null, null, null); assert gta.runAllTests(); // Sanity check. assert testsRun.size() == 3; assert testsRun.containsAll(expectedTestsRun); // Initial, final and single package set. expectedTestsRun = new HashSet<String>(); testsRun = new LinkedList<String>(); expectedTestsRun.add("a44.c.functiontest.FT"); gta = Helpers.setupForZip( new File(Grandtestauto.test44_zip), true, true, true, "a44.b", "a44.b.loadtest", "a44.c.functiontest", false, false, null, null, null, null, null, null, null, null); assert gta.runAllTests(); // Sanity check. assert testsRun.size() == 1; assert testsRun.containsAll(expectedTestsRun); return true; }