15. Run Multiple Solutions

Top  Previous  Next

This task is similar to 1. Running a solution but focused on running more than one solution at once. For that, one can redefine the tSolutionName and tSolutionFileName for each new run in the main method and repeat the process for every new ModelSolution. Or its also possible to add each ModelSolution to an extra method that can be called by main().

 

Another way is to use unit tests (JUnit) instead of a java application:

 

 


 

 

package net.simplace.sim.tests.training;

 

import org.junit.Test;

 

import net.simplace.sim.tests.ModulesStandardUnitTest;

 

public class UnitTestTraining extends ModulesStandardUnitTest

{

 // Declare folders paths

 String tSolutionFolder = "${_WORKDIR_}/training/solution/1_WorkingWithSolutions/";

 String tSolutionProjectsFolder = "${_WORKDIR_}/training/solution/2_WorkingWithProjects/";

 String tProjectFolder = "${_WORKDIR_}/training/project/";

 

 @Test

 public void Test_01_FirstSolution() throws Exception

 {

         String tSolutionFileName = tSolutionFolder + "01_FirstSolution.sol.xml";

         runSimulation(tSolutionFileName);

         showMessage("Finished Test 01_FirstSolution");

 }

 

 @Test

 public void Test_02_StartEndDates() throws Exception

 {

         String tSolutionFileName = tSolutionFolder + "02_StartEndDates.sol.xml";

         runSimulation(tSolutionFileName);

         showMessage("Finished Test 02_StartEndDates");

 }

 

}

 

 


 

 

Advantages of using unit tests are that they are simpler and can be ran individually in Eclipse. E.g. when the JUnit view is opened:

 

clip0028

 

 


 

Let's do it!

 

 

Task 15 Create a test than can run more than one solutions at a time.

 

Solution  

Follow the simplace_modules\unittest\net\simplace\sim\tests\training\UnitTestTraining.java click here

 

 

*ModelSolutions are found in simplace_modules\test\training\solution\1_WorkingWithSolutions