My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
SimpleIntegrationTest  
Creating Integration Tests with jSupervisor.
Updated Aug 18, 2010 by panwei...@gmail.com

The source for this test (or example) is availble in SimpleIntegrationTest.java

This example combines both SimpleUnitTest and SimpleUnitTestwithMock into a single integration test - testAuthentication_successful. The test scope is the same as that in SimpleUnitTestwithMock with two target objects declared in the class members.

1. iApp myApp ;  
2. iAuthentication myAuthentication ;  

The scenario is described as usual.

1. myApp.start() ; 
2. spec.expects(myApp,true) ; 
3. myAuthentication.authenticate("Mr Foo","bar"); 

Line 1 has jSupervisor invoking myApp.start(). Line 2 brings focus of control to myApp which expects a return true in the invocation in Line 3. Line 3 has myApp invoking myAuthentication.authenticate() with the parameters ("Mr Foo","bar").

Next, both proxies are attached with the actual classes and wired accordingly.

4. MyApp targetApp = new MyApp() ; 
5. supervisor.attach(myApp,targetApp) ; 
6. targetApp.setAuthentication(myAuthentication) ; 
7. MyAuthentication targetAuthentication = new MyAuthentication() ; 
8. supervisor.attach(myAuthentication,targetAuthentication) ; 
9. targetAuthentication.setAuthenticationServer(new MyAuthenticationServer()) ;  

Finally, the scenario (collaboration) is executed to completion.

10. ExecutionState state = supervisor.play() ; 
11. assertEquals(state, ExecutionState.COMPLETED);
Powered by Google Project Hosting