use of net.sf.sahi.test.TestRunner in project sakuli by ConSol.
the class SahiConnectorTest method testGetTestRunner.
@Test
public void testGetTestRunner() throws Exception {
when(sahiProxyProperties.getProxyPort()).thenReturn(9000);
final TestRunner testRunner = testling.getTestRunner();
final String s = testRunner.toString();
assertContains(s, "sahiHost = localhost");
assertContains(s, "port = 9000");
assertContains(s, "threads = 1");
}
use of net.sf.sahi.test.TestRunner in project sakuli by ConSol.
the class SahiConnectorTest method testStartSahiTestSuiteFAILURE.
@Test
public void testStartSahiTestSuiteFAILURE() throws Throwable {
TestRunner testRunnerMock = mock(TestRunner.class);
doReturn(testRunnerMock).when(testling).getTestRunner();
doReturn(SAKULI_HOME_FOLDER_PATH).when(testling).getIncludeFolderJsPath();
when(testRunnerMock.execute()).thenReturn("FAILURE");
when(testSuiteMock.getStopDate()).thenReturn(new Date());
testling.startSahiTestSuite();
verify(testRunnerMock).addReport(any(Report.class));
verify(testRunnerMock).setInitJS(anyString());
verify(testSuiteMock).setStopDate(any(Date.class));
verify(sakuliExceptionHandler).handleException(any(SakuliInitException.class));
verify(sahiProxy).shutdown();
verify(testling, never()).reconnect(any(Exception.class));
}
use of net.sf.sahi.test.TestRunner in project sakuli by ConSol.
the class SahiConnectorTest method testStartSahiTestSuiteReconnect.
@Test
public void testStartSahiTestSuiteReconnect() throws Throwable {
TestRunner testRunnerMock = mock(TestRunner.class);
doReturn(testRunnerMock).when(testling).getTestRunner();
when(testRunnerMock.execute()).thenThrow(new ConnectException("TEST"));
doNothing().when(testling).reconnect(any(Exception.class));
doReturn(SAKULI_HOME_FOLDER_PATH).when(testling).getIncludeFolderJsPath();
testling.startSahiTestSuite();
verify(testRunnerMock).addReport(any(Report.class));
verify(testRunnerMock).setInitJS(anyString());
verify(sakuliExceptionHandler, never()).handleException(any(SakuliInitException.class));
verify(sahiProxy).shutdown();
verify(testling).reconnect(any(Exception.class));
}
use of net.sf.sahi.test.TestRunner in project sakuli by ConSol.
the class SahiConnector method startSahiTestSuite.
/**
* starts a specific sahi test suite in sakuli
*/
public void startSahiTestSuite() throws SakuliInitException {
logger.info("Start Sakuli-Test-Suite from folder \"" + testSuite.getTestSuiteFolder().toAbsolutePath().toString() + "\"");
checkTestSuiteFile();
// ConnectionTester.checkTestCaseInitURL(testSuite);
//default sahi runner to play the sahi script
TestRunner runner = getTestRunner();
runner.setIsSingleSession(false);
//config reporter
runner.addReport(new Report("html", sakuliProperties.getLogFolder().toAbsolutePath().toString()));
//add include folder property
runner.setInitJS(getInitJSString());
try {
//is there to handle exceptions in the catch block from this.reconnect()
try {
countConnections++;
// Script-Runner starts
logger.info("Sahi-Script-Runner starts!\n");
//starts the script runner with the prefilled configurations
String output = runner.execute();
testSuite.setStopDate(new Date());
logger.info("test suite '" + testSuite.getId() + "' stopped at " + TestSuite.GUID_DATE_FORMATE.format(testSuite.getStopDate()));
logger.info("Sahi-Script-Runner executed with " + output);
//should only thrown if an exception could fetched by the backend of some reason
if (output.equals("FAILURE")) {
if (isSahiScriptTimout(testSuite.getException())) {
logger.warn("Sahi-Script-Runner timeout detected, start retry!");
SakuliException causingError = new SakuliException(testSuite.getException());
//reset all values
InitializingServiceHelper.invokeInitializingServcies();
this.reconnect(causingError);
} else if (testSuite.getException() == null) {
throw new SakuliInitException("SAHI-Proxy returned 'FAILURE' ");
}
}
} catch (ConnectException | IllegalMonitorStateException e) {
//Reconnect - wait for Thread "sahiRunner"
this.reconnect(e);
}
} catch (Throwable e) {
sakuliExceptionHandler.handleException(e);
} finally {
logger.info("test suite finished");
//shutdown sahi proxy!
sahiProxy.shutdown();
}
}
use of net.sf.sahi.test.TestRunner in project sakuli by ConSol.
the class SahiConnectorTest method testStartSahiTestSuiteOK.
@Test
public void testStartSahiTestSuiteOK() throws Throwable {
TestRunner testRunnerMock = mock(TestRunner.class);
doReturn(testRunnerMock).when(testling).getTestRunner();
doReturn(SAKULI_HOME_FOLDER_PATH).when(testling).getIncludeFolderJsPath();
when(testRunnerMock.execute()).thenReturn("OK");
when(testSuiteMock.getStopDate()).thenReturn(new Date());
testling.startSahiTestSuite();
verify(testRunnerMock).addReport(any(Report.class));
verify(testRunnerMock).setInitJS(anyString());
verify(testSuiteMock).setStopDate(any(Date.class));
verify(sakuliExceptionHandler, never()).handleException(any(SakuliInitException.class));
verify(sahiProxy).shutdown();
verify(testling, never()).reconnect(any(Exception.class));
}
Aggregations