Home » Eclipse Projects » SWTBot » How to test collaboration/concurrency between two RCP application instances ?
How to test collaboration/concurrency between two RCP application instances ? [message #1386805] |
Fri, 20 June 2014 15:43  |
Laurent Le Moux Messages: 184 Registered: September 2011 |
Senior Member |
|
|
Hi all,
I wrote an application to work in a collaborative way. And now, I need to test - for exemple - that when a first user modifies a diagram, a second one won't be allowed to. In other words, I want to check that my underlying locking mechanism is working fine.
I considered three scenarios based on SWTBot and I would appreciate any tips or recommendations.
Scenario 1 : Two SWTBot instances running in parallel. Theoretically simple to launch and distribute the tests but how to synchronise the execution between the two instances to make sure the tests are executed in the correct order ?
Scenario 2 : Two nested SWTBot instances. The first one should launch the second one and handle it during the whole tests execution, that is, keep it alive and provide the tests to be executed when appropriate.
Scenario 3 : One SWTBot instance coupled with "headless" junit tests.
The JUnit tests would programmatically achieve the same actions that would have been performed using the HMI.
At the first glance, scenario 3 looks easier to set up than the second one.
But scenario 2 seems to be the more appealing. Writing SWTBot test could mean less code writing than for headless junit tests. And this scenario is closer to reality than the third one.
Therefore, is the 2nd scenario the best one and a feasible strategy ? If yes, how to programmatically create the second nested SWTBot instance ? How to keep it alive and pass it along the whole execution ? And, how to provide it with its own tests to be executed when appropriate ?
Kind regards,
Laurent
|
|
|
Re: How to test collaboration/concurrency between two RCP application instances ? [message #1386973 is a reply to message #1386805] |
Mon, 23 June 2014 10:52   |
|
On 06/20/2014 05:43 PM, Laurent Le Moux wrote:
> I wrote an application to work in a collaborative way. And now, I need
> to test - for exemple - that when a first user modifies a diagram, a
> second one won't be allowed to. In other words, I want to check that my
> underlying locking mechanism is working fine.
SWTBot by itself doesn't provide much more than the finder APIs when in
comes to test execution, so there is nothing magic to help you there.
AFAIK, there is no generic Eclipse project or technology to deal with
collaboration/orchestration between multiple RCP applications. I guess
you'll have to do it more or less manually.
> Scenario 1 : Two SWTBot instances running in parallel. Theoretically
> simple to launch and distribute the tests but how to synchronise the
> execution between the two instances to make sure the tests are executed
> in the correct order ?
That's the solution I'd go for in that case:
Both application could connect to a remote notification service (you
could think of using any protocol you like such as simple TCP or UDP,
RMI, MQTT or even just a shared file) and would send event when they
finished a piece of action and listen to incoming events and react when
it's ready.
Depending on the protocol, in order to make an application test pause
while the other is processing, you could either just use a synchronous
method "protocol.receive()"-like, or for example if you go for
filesystem, implement an ICondition and use it in bot.waitUntil or
bot.waitWhile method.
Eg
bot.waitUntil(new ICondition() {
File f = new File("collaborationStatusFile");
@Override public boolean test() {
return someGetFileContentAsStringMethod(f).contains("other
application notify job is done");
}
}
> Scenario 2 : Two nested SWTBot instances. The first one should launch
> the second one and handle it during the whole tests execution, that is,
> keep it alive and provide the tests to be executed when appropriate.
Even if you do that, it will be 2 separate processes so you can't
orchestrate them without a synchronization mechanism as discussed above.
IMO, this is too complex and doesn't provide anything helpful for your case.
> Scenario 3 : One SWTBot instance coupled with "headless" junit tests.
> The JUnit tests would programmatically achieve the same actions that
> would have been performed using the HMI.
In general, being able to do thing headlessly is a big plus. If that's
something you achieved and that still make your test relevant, it's
definitely something interesting to do as it will make everything a bit
easier.
> But scenario 2 seems to be the more appealing. Writing SWTBot test could
> mean less code writing than for headless junit tests. And this scenario
> is closer to reality than the third one.
>
> Therefore, is the 2nd scenario the best one and a feasible strategy ? If
> yes, how to programmatically create the second nested SWTBot instance ?
> How to keep it alive and pass it along the whole execution ? And, how to
> provide it with its own tests to be executed when appropriate ?
Scenario 2 is a superset of Scenario 1.
If I were to do this kind of work, I would go for scenario 1, relying on
a simple synchronous notification protocol to wait for n-way
notification between applications.
HTH,
--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
|
|
| | | | |
Goto Forum:
Current Time: Wed Dec 06 22:17:33 GMT 2023
Powered by FUDForum. Page generated in 0.02208 seconds
|