Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
junitintegration [2020/03/19 16:41]
admin removed
— (current)
Line 1: Line 1:
-===== Integration: JUnit===== 
-First you must have //TestOptimal// installed in your IDE by following [[overview:installdoc|Installation]]. 
  
-To execute MBT model or execute a specific test case (mCase), create the test java class inheriting from test case as you normally do to create JUnit class. Add a //static initializer// as the following to start up //TestOptimal// server and to open the MBT model. 
- 
-Now you are ready to write your test case to execute MBT model or a specific test case (mCase) in the model. See example below. 
- 
-Make sure you do not have any instance of //TestOptimal// running as JUnit class will try to start //TestOptimal// server as part of the startup process. 
- 
-   import junit.framework.TestCase; 
-   import com.webmbt.TestOptimalClient; 
-   public class JUnitWebStore extends TestCase { 
-     /** 
-      * Example to run a specific mCase.  It is assumed that sequencer/mode has been set to mCaseSequencer and 
-      * appropriate plugin/browser settings have been set appropriately. 
-      * @throws Exception 
-      */ 
-      public void testRemoveItemScenario() throws Exception { 
-         TestOptimalClient.executeModel("RemoveItemScenario", "Junit testing RemoveItemScenario"); 
-      } 
-     /** 
-      * Example to run the model.  It is assumed that sequencer/mode has been set to mCaseSequencer and 
-      * appropriate plugin/browser settings have been set appropriately. 
-      * @throws Exception 
-      */ 
-      public void testQuickPurchaseScenario() throws Exception { 
-         TestOptimalClient.executeModel(null, "Junit testing complete model"); 
-      } 
-     /** 
-      * starts up **//TestOptimal//** server and opens the mbt model. 
-      */ 
-      static { 
-      try { 
-     TestOptimalClient.startTestOptimalServer(new String[]{}); 
-             TestOptimalClient.openModel("WebStore.scxml"); 
-          } 
-  catch (Exception e) { 
-     e.printStackTrace(); 
-  } 
-      } 
-    }