Waiting for a job in a unit test? [message #1446846] |
Fri, 17 October 2014 07:48  |
Eclipse User |
|
|
|
In our project we use a Job to refresh the whole form during execChangedValue(). We have a Junit test with a Scout Context where the Server is mocked.
Since the introduction of the Job (to solve loop detection problems), we have the problem that the Unit no longer works. Here some code:
// install the mocked services with TestingUtility.registerServices(..)
// The process service defined the behavior for: load() and calculate()
// * loadFormData for OtherField contains LOADED_VALUE
// * calcFormData for OtherField contains CALCULATED_VALUE
when(service.load(any(MyFormData.class))).thenReturn(loadFormData);
when(service.calculate(any(MyFormData.class))).thenReturn(calcFormData);
Form f = new Form();
f.startNew();
assertEquals(LOADED_VALUE, f.getOtherField().getValue());
f.getMyField().setValue(NEW_VALUE); //<= this triggers a calculate job
// TODO: how to tell the test he should wait on the calculate_job?
assertEquals(CALCULATED_VALUE, f.getOtherField().getValue());
verify(service, times(1)).calculate(any(MyFormData.class));
The assertion for the calculated value is not working.
When I debug, I see that I have a job/threading problem.
Thank you in advance.
.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04489 seconds