You can use a C# program to create Scenarios and TestCases. This is particularly useful when creating a large number of similar tests. The C#TestCreation sample demonstrates this capability.
Click here to download the sample: https://github.com/DanlawMxTeam/Samples/raw/master/C%23TestCreation.rar
•MxSuite 3.40 or later
•A supported version of Visual Studio is required.
•The user should have an understanding of Visual Studio, MxSuite Scenarios, TestCases, and Triggers.
Follow this procedure to use the program:
1.Copy the sample project to your user directory. See Sample Projects.
2.Open the MxVDev project (MxV.mxp). Notice that it has no Scenarios or TestCases.
3.Open the solution, CSharpScenarioGeneration.sln, in Visual Studio.
4.Set the Reference Path:
a.Right-click on the CSharpScenarioGeneration project (not the solution) and select Properties:
b.Select Reference Paths.
c.Click the browse button () and browse to the bin subfolder of the MxSuite Installation Folder.
d.Click the Add Folder button.
Note: It may be necessary to modify the code in the CSharpScn.cs file to specify the path where the Scenario and TestCases are created. The default is the ScenariosAndTestCases folder in the project folder.
5.Build the MSVS solution.
6.If not already present, create a new subfolder, ScenariosAndTestCases, in the project folder (C#TestCreation):
7.Run the program. (Use Debug->Start Without Debugging.)
8.The sample program creates the following files in the ScenariosAndTestCases folder:
•One Scenario: CSharpScn.mxs
•Four TestCases: Init.mxc, TestSample.mxc, MessageSampleTestCase.mxc, and Tick.mxc
8.In MxVDev, use the Project Explorer to view the Scenario and TestCases.
You can examine the sample C# code in Visual Studio. You can see the code used for the following:
•Read Signal properties from the Signal Dictionary
•Create a Scenario
•Create and save TestCases
•Add TestCases to the Scenario
•Save the Scenario
•Add Transitions to a Signal
•Add a trigger and Relative Time Criteria to the TestCase
You can use the Visual Studio auto-complete function to see the methods and enumerations available:
This code example shows how to add a transitions to input and output Signals. The parameters are: Simulated time, value, real time, and comment. In this program, the simulated time and real time are always the same.
inVal.AddInValTransition(0.0, new Discrete(0), 0.0, "Transition 1");
outVal.AddOutValTransition(0.5, new Discrete(0), 0.5, "Transition 2");
This code example shows how to add a triggers to a Signal. Trigger on change is the only option currently available.
inVal.AddTriggerOnChange("trig_2", "SampleTrigger2", 3, MicroMax.MxVDev.Triggers.TriggerAction.SetTestCaseComplete);