@BeforeClass(alwaysRun = true) public void initTC() throws Exception { if (testSuite == null) { initTestSuiteParameter(); } LOGGER.info("............................INITIALIZE TEST-CASE with {}", initParameter); String testCaseName = this.getClass().getSimpleName(); initParameter = getTestCaseInitParameter(); if (initParameter == null) { throw new SakuliException("init parameter have to be set!"); } testSuite = BeanLoader.loadBean(TestSuite.class); // start sahi controlled browser if needed initSahiBrowser(); testSuite.addTestCase(new TestCaseBuilder(testCaseName, initParameter.getTestCaseId()).build()); testCaseAction = BeanLoader.loadTestCaseAction(); // add the the testcase folder as image folder if (Files.exists(getTestCaseFolder())) { initParameter.addImagePath(getTestCaseFolder().toString()); } initTestCaseAction(initParameter); LOGGER.info( "............................START TEST-CASE '{}' - {}", initParameter.getTestCaseId(), testCaseName); counter = 0; startTimeCase = DateTime.now(); }
/** * Initialize the image folders, warning time and critical time for the current testcase with the * assigned initParameter. * * @param initParameter a initialized object of {@link TestCaseInitParameter}. */ protected void initTestCaseAction(TestCaseInitParameter initParameter) { List<Path> imagePaths = initParameter.getImagePaths(); testCaseAction.initWithPaths( this.initParameter.getTestCaseId(), this.initParameter.getWarningTime(), this.initParameter.getCriticalTime(), imagePaths.toArray(new Path[imagePaths.size()])); }
@AfterClass(alwaysRun = true) public void stopTC() throws Exception { if (executorService != null) { executorService.awaitTermination(1, TimeUnit.MILLISECONDS); } String testCaseName = this.getClass().getSimpleName(); LOGGER.info( "............................ SAVE RESULTS OF TEST-CASE '{}' - {}", initParameter.getTestCaseId(), testCaseName); testCaseAction.saveResult( initParameter.getTestCaseId(), String.valueOf(startTimeCase.getMillis()), String.valueOf(DateTime.now().getMillis()), null, null); if (browser != null) { browser.close(); } }
protected Path getTestCaseFolder() { return Paths.get(getTestSuiteFolder() + File.separator + initParameter.getTestCaseFolderName()); }