@Test public void testResolveTakeScreenshotFolder() throws Exception { TestCase tc = mock(TestCase.class); Path examplePath = Paths.get(BaseTest.TEST_FOLDER_PATH + File.separator + "case" + File.separator + "tc.js"); when(tc.getTcFile()).thenReturn(examplePath); when(loader.getCurrentTestCase()).thenReturn(tc); Path result = testling.resolveTakeScreenshotPath("screenshot.png"); assertEquals(result.toString(), BaseTest.TEST_FOLDER_PATH + File.separator + "case" + File.separator + "screenshot.png"); verify(loader, never()).getTestSuite(); verify(loader).getCurrentTestCase(); }
public Path resolveTakeScreenshotPath(String filename) { Path path = Paths.get(filename); if (path.isAbsolute()) { return path; } TestCase currentTestCase = baseActionLoader.getCurrentTestCase(); Path folderPath = currentTestCase != null ? currentTestCase.getTcFile().getParent() : null; if (folderPath == null || !Files.exists(folderPath)) { LOGGER.warn("The test case folder could not be found => Fallback: Use test suite folder!"); folderPath = baseActionLoader.getTestSuite().getTestSuiteFolder(); } return folderPath.resolve(filename); }
ScreenshotActions { public Path resolveTakeScreenshotPath(String filename) { Path path = Paths.get(filename); if (path.isAbsolute()) { return path; } TestCase currentTestCase = baseActionLoader.getCurrentTestCase(); Path folderPath = currentTestCase != null ? currentTestCase.getTcFile().getParent() : null; if (folderPath == null || !Files.exists(folderPath)) { LOGGER.warn("The test case folder could not be found => Fallback: Use test suite folder!"); folderPath = baseActionLoader.getTestSuite().getTestSuiteFolder(); } return folderPath.resolve(filename); } }
ScreenshotActions { public Path resolveTakeScreenshotPath(String filename) { Path path = Paths.get(filename); if (path.isAbsolute()) { return path; } TestCase currentTestCase = baseActionLoader.getCurrentTestCase(); Path folderPath = currentTestCase != null ? currentTestCase.getTcFile().getParent() : null; if (folderPath == null || !Files.exists(folderPath)) { LOGGER.warn("The test case folder could not be found => Fallback: Use test suite folder!"); folderPath = baseActionLoader.getTestSuite().getTestSuiteFolder(); } return folderPath.resolve(filename); } @Autowired  ScreenshotActions(Screen screen, ActionProperties props, @Qualifier("baseLoader") BaseActionLoader baseActionLoader); }
ScreenshotActions { public Path resolveTakeScreenshotPath(String filename) { Path path = Paths.get(filename); if (path.isAbsolute()) { return path; } TestCase currentTestCase = baseActionLoader.getCurrentTestCase(); Path folderPath = currentTestCase != null ? currentTestCase.getTcFile().getParent() : null; if (folderPath == null || !Files.exists(folderPath)) { LOGGER.warn("The test case folder could not be found => Fallback: Use test suite folder!"); folderPath = baseActionLoader.getTestSuite().getTestSuiteFolder(); } return folderPath.resolve(filename); } @Autowired  ScreenshotActions(Screen screen, ActionProperties props, @Qualifier("baseLoader") BaseActionLoader baseActionLoader); Path takeScreenshot(Path picturePath); Path takeScreenshot(String filename, Rectangle rectangle); Path takeScreenshot(Path picturePath, Rectangle rectangle); Path takeScreenshotWithTimestamp(final String filenamePostfix, final String optFolderPath, final String optFormat, Rectangle optRectangle); Path takeScreenshotWithTimestamp(String message, Path folderPath); Path takeScreenshotWithTimestamp(String message, Path folderPath, String format, Rectangle rectangle); Path takeScreenshotWithTimestampThrowIOException(String message, Path folderPath, String format, Rectangle rectangle); Path resolveTakeScreenshotPath(String filename); }
ScreenshotActions { public Path resolveTakeScreenshotPath(String filename) { Path path = Paths.get(filename); if (path.isAbsolute()) { return path; } TestCase currentTestCase = baseActionLoader.getCurrentTestCase(); Path folderPath = currentTestCase != null ? currentTestCase.getTcFile().getParent() : null; if (folderPath == null || !Files.exists(folderPath)) { LOGGER.warn("The test case folder could not be found => Fallback: Use test suite folder!"); folderPath = baseActionLoader.getTestSuite().getTestSuiteFolder(); } return folderPath.resolve(filename); } @Autowired  ScreenshotActions(Screen screen, ActionProperties props, @Qualifier("baseLoader") BaseActionLoader baseActionLoader); Path takeScreenshot(Path picturePath); Path takeScreenshot(String filename, Rectangle rectangle); Path takeScreenshot(Path picturePath, Rectangle rectangle); Path takeScreenshotWithTimestamp(final String filenamePostfix, final String optFolderPath, final String optFormat, Rectangle optRectangle); Path takeScreenshotWithTimestamp(String message, Path folderPath); Path takeScreenshotWithTimestamp(String message, Path folderPath, String format, Rectangle rectangle); Path takeScreenshotWithTimestampThrowIOException(String message, Path folderPath, String format, Rectangle rectangle); Path resolveTakeScreenshotPath(String filename);  }