Cameo Simulation Toolkit 19.0 LTR SP1 Documentation


In these scenarios, all related items on this page to be used are in the sample.

To prepare a simulation project and Configs in MagicDraw

  1. Create a simulation model with Behaviors, e.g., TestVerdictKind.mdzip.
  2. Apply «TestCase» to the Behaviors so the pass/fail status will be returned to the VerdictKind Activity parameters.
  3. Create Simulation Configs and set those Behaviors as executionTarget of those Simulation Configs.


    All required resources must be available for the Simulation Configs, e.g., loadCSV and fmu. All features preventing simulation from the start/terminate, e.g., false autoStart, context without Classifier Behavior, chart windows at the end of execution, or output parameters at the end of execution (running Activity) will also be automatically started/terminated.

  4. Run each Simulation Config to verify that an expected result, either pass or fail, must be returned.

    Preparing a simulation project and Configs in MagicDraw.

To run a project through simulate command line

  1. Run the command line console, e.g., cmd on Windows.
  2. In the console, type any commands to go to the local installation of MagicDraw.
  3. Go to the plugins\com.nomagic.magicdraw.simulation folder.
  4. Use the following simulate command syntax: simulate -project “[Path of an MDZIP project]” -config “[Config]”.

    In this case, the following commands are used:

    simulate -project “D:\\Simulation\\API\\TestVerdictKind.mdzip” -config “Run GeneratePassResult”
    simulate -project “D:\\Simulation\\API\\TestVerdictKind.mdzip” -config “Run GenerateFailResult”
  5. At the last line of the command prompt, pass or fail appears. You can also see the details of execution through the Simulation Log File.

    Running the project through the simulate command line.

To create a JUnit test case and configuration file

  1. Include the JUnit library in the Java project by creating a new Java project and adding the JUnit 4 library in current location using the Eclipse's JUnit.
  2. Create a new JUnit test case, e.g., Test Simulation Command
  3. Compile the test case and create a JAR file, e.g., TestSimulationCommandLine.JAR from the test case.
  4. Create properties file, e.g., and

To configure Jenkins for the Automated testing

  1. Create a new Jenkins project.
  2. Specify a Project Name, e.g., Test Simulation Command Line.
  3. Go to Advanced Project Options, click Advanced, and select Use custom workspace.

  4. In the Directory box, specify a path to the directory that contains run_junit.xml (Ant configuration file).
  5. Go to Build and click Add build step. Select Invoke Ant.
  6. In the Targets box, type build.

  7. Select Advanced. In the Build File box, type run_junit.xml.
  8. In the Properties box, specify md.root=[MagicDraw installation directory] and properties.files.dir=[Path containing the properties files], as shown in the example above.


    The path containing the property files can be either an absolute (full) path, e.g., C:\Users\User\Desktop\TestSimulationCommandLine\tests or relative path, e.g., tests.

  9. Go to Post-build Actions and click Add post-build action. Select Publish JUnit test result report.
  10. In the Test report XMLs box, specify a path to JUnit XML files, e.g., test-reports/**TEST*.xml.

  11. Run the build. Test Result will be shown and allows you to view more details for those test cases.

    Test Result of the simulation command line is shown on the Jenkins page.

Simulate command arguments and parameters

Examples of the simulate command lines are as follows:

  • On Windows: simulate.bat -project "../../samples/simulation/HingeMonteCarloAnalysis.mdzip" -config "Monte Carlo Analysis"
  • On Mac OS: sh -project "../../samples/simulation/HingeMonteCarloAnalysis.mdzip" -config "Monte Carlo Analysis"

Type of argument



Mandatory argument


Specify a file name with the path of a MagicDraw project. Both relative and absolute paths are supported.


Specify a SimulationConfig without a qualified name to run.


If SimulationConfig has duplicate names (in different package), a warning message will be displayed in the Simulation log, and the first name will be used.

-properties propertiesFileName

Specify the name of a properties file to use, e.g., in the sample.


  • If the -properties option is specified, the argument is the name of a properties file, and the mandatory argument is no longer required.
  • A properties file contains -project and -config, along with the specified data of each parameter.

Optional (server) argument


Specify type of the server to connect, <tw> or <twcloud>, where <tw> is Teamwork Server, as the default type of the server, and <twcloud> is Teamwork Cloud.

-serverSpecify a name or an IP Address (and port) of the server.

Specify a login name to log on to the server.


Specify a password to log on to the server.


Specify to use and enable Secured Connection (SSL), <true> or <false> as the default value.


Specify the version of the server project.


Specify the tag name of the server project. 


  • -tag can't be used with -pversion.
  • If multiple projects are returned, only the latest version will be run.

Teamwork Cloud argument


Specify a branch of Teamwork Cloud projects. 


  • -branch and -pversion cannot be specified in the same command.
  • If -pversion and -tag are not specified, the latest version of the specified branch will be returned.
-updatemoduleSpecify update project usages if required, <true> or <false>, where <false> is the default.

Specify a project password.

JUnit test sample:

package com.nomagic.magicdraw.simulation;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static;

import java.nio.file.Files;
import java.nio.file.Path;

import org.junit.Before;
import org.junit.Test;

 * A test class for running the simulation command line and checking for the pass/fail result.
 * @author Chanon S.

public class TestSimulationCommandLine {
	private static final String MD_ROOT_PROPERTY = "md.root";
	private static final String PROPERTIES_FILES_PROPERTY = "properties.files.dir";
	private static final String MD_DIR = System.getProperty(MD_ROOT_PROPERTY);
	private static final String SIMULATION_COMMAND_LINE = MD_DIR + "/plugins/com.nomagic.magicdraw.simulation/";
	private static final String PROPERTIES_FILES_DIR = System.getProperty(PROPERTIES_FILES_PROPERTY);
	private static final String PASS_PROPERTIES = "";
	private static final String FAIL_PROPERTIES = "";
	private static final String SYSTEM_NEW_LINE = System.getProperty("line.separator");

	public void assertBuildExist() {
		System.out.println(MD_ROOT_PROPERTY + "=" + MD_DIR);

		assertNotNull(MD_ROOT_PROPERTY + " is not specified.", MD_DIR);
		assertNotNull(PROPERTIES_FILES_PROPERTY + " is not specified.", PROPERTIES_FILES_DIR);

		assertTrue("MagicDraw directory does not exist, MD_DIR=" + MD_DIR, new File(MD_DIR).exists());
		assertTrue("Properties files directory does not exist,PROPERTIES_FILES_DIR=" + PROPERTIES_FILES_DIR, new File(PROPERTIES_FILES_DIR).exists());
		assertTrue("Could not find file, SIMULATION_COMMAND_LINE=", new File(SIMULATION_COMMAND_LINE).exists());

	@Test(timeout = 120000)
	public void testGeneratePassResult() {
		// This project and Simulation Config generate "pass" as the result of TestCase.
		String propertyFilePath = PROPERTIES_FILES_DIR + "/" + PASS_PROPERTIES;
		String consoleOutput = runWithProperties(propertyFilePath);
		System.out.println("Console output=" + consoleOutput);		
		boolean result = consoleOutput.contains(SYSTEM_NEW_LINE + "pass" + SYSTEM_NEW_LINE);
		assertTrue(consoleOutput, result);

	@Test(timeout = 120000)
	public void testGenerateFailResult() {
		// This project and Simulation Config generate "fail" as the result of TestCase.
		String propertyFilePath = PROPERTIES_FILES_DIR + "/" + FAIL_PROPERTIES;
		String consoleOutput = runWithProperties(propertyFilePath);
		boolean result = consoleOutput.contains(SYSTEM_NEW_LINE + "pass" + SYSTEM_NEW_LINE);
		assertTrue(consoleOutput, result);

	private String execute(String command) {
		System.out.println("Executing, command=" + command);

		StringBuilder result = new StringBuilder();
		try {
			Process p = Runtime.getRuntime().exec(command);
			BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
			String line;
			while ((line = input.readLine()) != null) {
		} catch (IOException e) {
		return result.toString();

	private String runWithProperties(String propFilePath) {
		String absPropPath = propFilePath;
		if (propFilePath != null) {
			Path path = new File(propFilePath).toPath();
			if (!Files.exists(path)) {
				fail("Properties file <" + propFilePath + "> not found.");
			} else {
				absPropPath = path.toAbsolutePath().toString();
		String cmd = propFilePath == null || propFilePath.isEmpty() ? SIMULATION_COMMAND_LINE : SIMULATION_COMMAND_LINE + " -properties \"" + absPropPath + "\"";
        return execute(cmd);

Ant configuration file sample: run_junit.xml

<project name="Run JUnit and Generate Reports" default="build" basedir=".">
	<target name="build" depends=", prepare, run.junit" />    
	<target name="">
		<property name="md.root" location="${md.root}" />
		<property name="properties.files.dir" location="${properties.files.dir}" />
		<property name="test.reports.dir" location="test-reports"/>
	<target name="prepare">
		<delete dir="${test.reports.dir}" />
		<mkdir dir="${test.reports.dir}" />
	<target name="run.junit">
		<junit printsummary="yes" fork="yes">
				<pathelement location="lib/TestSimulationCommandLine.jar"/>
				<pathelement location="lib/junit-4.12.jar"/>
				<pathelement location="lib/hamcrest-core-1.3.jar"/>
			<jvmarg value="-Xmx1200m" />
			<jvmarg value="-Xms256m" />
			<jvmarg value="-XX:PermSize=128M" />
			<jvmarg value="-XX:MaxPermSize=256M" />
			<jvmarg value="-XX:-UseSplitVerifier" />
			<jvmarg value="-noverify" />

			<sysproperty key="md.root" value="${md.root}" />
			<sysproperty key="properties.files.dir" value="${properties.files.dir}" />

			<batchtest todir="${test.reports.dir}">
				<zipfileset src="lib/TestSimulationCommandLine.jar">
					<include name="**/*.class"/>
			<formatter type="xml" />
  • No labels