-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSysMLTestCase.java
More file actions
151 lines (143 loc) · 5.09 KB
/
Copy pathSysMLTestCase.java
File metadata and controls
151 lines (143 loc) · 5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package sysmlinjava.tests;
import java.util.Optional;
import sysmlinjava.blocks.SysMLBlock;
import sysmlinjava.common.SysMLActivity;
/**
* SysMLinJava's representation of SysML's TestCase. The {@code SysMLTestCase}
* contains the activities to be performed for a test case. Optional activities
* are included for initialization and finalization activities before and after
* the test execution activity.
* <p>
* Extension classes of the {@code SysMLTestCase} are typically parts of a class
* that is an extension of {@code SysMLTest}. The activities of
* the{@code SysMLTestCase} are executed in the context of the {@code SysMLTest}
* as a series of test cases that make up the test. The extension of the
* {@code SysMLTestCase} should instantiated and added to the set of test cases
* in the {@code SysMLTest}. This instantiation of the test cases should be
* performed within the overridable operation {@code createTestCases()}
* operation of the {@code SysMLTest}.
* <p>
* <b>Note:</b>Realization of the initialization, test, and finalization
* interfaces must each be instances of a lambda expression. These lambda
* expressions for these activities must be declared in the
* {@code createInitializeActivity()}, {@code createExecuteActivity()}, {@code
* createFinalizeActivity()}. Tools and other elements of the current version of
* SysMLinJava do not recognize class-based realizations of these activities. In
* addition, the instantiations of these functional interfaces as lambda
* expressions will have access to the {@code SysMLTest} class that includes the
* system under test (SUT). Having no input parameters, the test case activity
* lambda expressions have direct visibility to the test which provides access
* to any ports, parts, values, or constraints that might be declared within the
* test class and needed by the activities of the test case.
*
* @author ModelerOne
*
* @see SysMLTest
*/
public abstract class SysMLTestCase extends SysMLBlock
{
/**
* Test of which this is a test case. The test contains the system-under-test as
* well as any ports, parts, values, or constraints that might be needed by the
* test case activities.
*/
public SysMLTest test;
/**
* Initialization behavior to be performed before the execution activity
*/
public Optional<SysMLActivity> initialize;
/**
* Execution activity to be performed as the test case
*/
public SysMLActivity execute;
/**
* Finalization behavior to be performed after the execution activity
*/
public Optional<SysMLActivity> finalize;
/**
* Verdict of performance of the test case
*/
public SysMLVerdictKind verdict;
/**
* Constructor
*
* @param test The test of which this test case is a part of
*/
public SysMLTestCase(SysMLTest test)
{
super();
this.test = test;
this.initialize = Optional.empty();
this.finalize = Optional.empty();
createInitializeActivity();
createExecuteActivity();
createFinalizeActivity();
}
/**
* Creates the activity to be invoked prior to the execute activity ostensibly
* to initialize the test case. This operation should assign a lambda expression
* to the {@code initialize} variable. An example of the operation is as
* follows:
*
* <pre>
* initialize = Optional.of(() ->
* {
* testVarA = 1.0;
* testVarB = getBetaValue();
* testVarC = List.of("ipso", "facto");
* verdict = SysMLVerdictKind.fail;
* });
* </pre>
*/
protected void createInitializeActivity()
{
}
/**
* Mandatory operation to create the test case execution activity. This
* operation should assign a lambda expression to the {@code execute} variable.
* An example of the operation is as follows:
*
* <pre>
* execute = () ->
* {
* for (int i = 0; i %lt; 1000; i++)
* {
* test.system.transmit(testVarA);
* int received = test.systemreceive();
* if (received != null @@ received == testVarA)
* testVarA += i * Math.random();
* }
* };
* </pre>
*/
protected abstract void createExecuteActivity();
/**
* Creates the activity to be invoked after the execute activity ostensibly to
* finalize the test case. This operation should assign a lambda expression to
* the {@code finalize} variable. An example of the operation is as follows:
*
* <pre>
* finalize = Optional.of(() ->
* {
* if (testVarA == correctResult)
* verdict = SysMLVerdictKind.pass;
* storeResultsTo(resultsFile);
* });
* </pre>
*/
protected void createFinalizeActivity()
{
}
/**
* Name of method to create initialize activity, used by SyMLinJava tools
*/
public static final String createInitializeActivityMethodName = "createInitializeActivity";
/**
* Name of method to create execute activity, used by SyMLinJava tools
*/
public static final String createExecuteActivityMethodName = "createExecuteActivity";
/**
* Name of method to create finalize activity, used by SyMLinJava tools
*/
public static final String createFinalizeActivityMethodName = "createFinalizeActivity";
}