private static String getTestInfo(IOpenMethod testMethod, int numberOfTests) { String info = null; if (testMethod instanceof TestSuiteMethod) { TestSuiteMethod testSuite = (TestSuiteMethod) testMethod; if (testSuite.isRunmethod()) { if (numberOfTests < 1) { info = "No runs"; } else if (numberOfTests == 1) { info = numberOfTests + " run"; } else { info = numberOfTests + " runs"; } } else { if (numberOfTests < 1) { info = "No test cases"; } else if (numberOfTests == 1) { info = numberOfTests + " test case"; } else { info = numberOfTests + " test cases"; } } } return info; } }
/** * Checks if the tester is instance of {@link TestSuiteMethod}, if it has * any parameters for testing(see * {@link TestSuiteMethod#isRunmethodTestable()}) and if there is no errors * in it. * * @param tester instance of method that is considered to be a test. * @return true if tester is valid {@link TestSuiteMethod}. */ public static boolean isTester(IOpenMethod tester) { if (tester instanceof TestSuiteMethod) { try { TestSuiteMethod testSuiteMethod = (TestSuiteMethod) tester; return !testSuiteMethod.isRunmethod() && testSuiteMethod.isRunmethodTestable() && (testSuiteMethod.getSyntaxNode() == null || !testSuiteMethod.getSyntaxNode().hasErrors()); } catch (Exception e) { Logger log = LoggerFactory.getLogger(ProjectHelper.class); log.error(e.getMessage(), e); return false; } } return false; }
public static boolean isMethodRunnedBy(IOpenMethod tested, IOpenMethod runner) { if (!(runner instanceof TestSuiteMethod)) { return false; } if (runner == tested) { return true; } IOpenMethod toTest = ((TestSuiteMethod) runner).getTestedMethod(); return toTest == tested && ((TestSuiteMethod) runner).isRunmethod(); }
public boolean isRunmethod() { return testSuite.getTestSuiteMethod().isRunmethod(); }
public TestSuiteMethod(IOpenMethod testedMethod, TestSuiteMethod copy) { super(copy.getHeader(), copy.getBoundNode()); db = copy.db; this.testedMethod = testedMethod; initProperties(copy.getMethodProperties()); this.runmethod = copy.isRunmethod(); this.testObjects = copy.getTestObjects(); this.descriptors = copy.getDescriptors(); this.setUri(copy.getUri()); }
public static String createTestName(IOpenMethod testMethod) { IMemberMetaInfo mi = testMethod.getInfo(); TableSyntaxNode tnode = (TableSyntaxNode) mi.getSyntaxNode(); String name = TableSyntaxNodeUtils.getTableDisplayValue(tnode)[1]; if (testMethod instanceof TestSuiteMethod) { TestSuiteMethod testSuite = (TestSuiteMethod)testMethod; if (testSuite.isRunmethod()) { if (testSuite.nUnitRuns() < 1) { name += getTestAdditionalInfo(NO, RUNS); } else { name += getNumberOfTests(testSuite.nUnitRuns(), RUNS); } } else { if (testSuite.getNumberOfTests() < 1) { name += getTestAdditionalInfo(NO, TEST_CASES); } else { name += getNumberOfTests(testSuite.getNumberOfTests(), TEST_CASES); } } } return name; }