|
Re: Scout Tests with Timeout [message #1395719 is a reply to message #1386918] |
Mon, 07 July 2014 09:44 |
Rainer N. Messages: 9 Registered: January 2014 |
Junior Member |
|
|
I found a solution to run such tests:
The testing logic must be wrapped within a ServerJob.
As ServerJob.getCurrentSession() returns null, an own server session must be instantiated.
@Test(timeout = 5000)
public void testTimeout() throws Throwable {
TestJob job = new TestJob() {
@Override
protected void executeTest() {
//Testing logic with assertions
}
};
job.runAndCheckAssertions();
}
abstract class TestJob extends ServerJob {
private Throwable m_throwable;
public TestJob() {
super("Test", new CoreProductServerTestSession());
m_throwable = null;
}
@Override
protected IStatus runTransaction(IProgressMonitor monitor) throws Exception {
try {
executeTest();
}
catch (Throwable t) {
m_throwable = t;
}
return Status.OK_STATUS;
}
public void runAndCheckAssertions() throws Throwable {
runNow(null);
if (m_throwable != null) {
throw m_throwable;
}
}
protected abstract void executeTest();
}
CoreProductServerTestSession is a class implementing IServerSession.
[Updated on: Mon, 07 July 2014 12:13] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03041 seconds