Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: bba67dc4caa2e5df591c092c50bdccaf89873f42 (plain) (blame)
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216

__TOC__
= Papyrus Test Generation Framework =
<span id="_m2q_0CHAEeWLGf5EjabojA">
==Framework Goals==
* Automate the  development of test cases for Papyrus diagrams
* Set the bases for a model-based testing approach
* Ease the transition towards test-driven development</span>
<span id="_m2rm4SHAEeWLGf5EjabojA">Currently, the framework supports the generation of unit tests for a diagram editor, taking as input an input .gmfgen. See below the generation workflow to understand how it works.</span>
==<span id="_m2sN8SHAEeWLGf5EjabojA">Table of Contents</span>==
:[[#_m2tcESHAEeWLGf5EjabojA|Requirements]]
:[[#_m20JwCHAEeWLGf5EjabojA|Use Cases]]
::[[#_m4-F4SHAEeWLGf5EjabojA|Papyrus Test Generation Framework]]
::[[#_m4_UACHAEeWLGf5EjabojA|Define list of element edit parts under test]]
::[[#_m5AiISHAEeWLGf5EjabojA|Generate test model]]
::[[#_m5CXUSHAEeWLGf5EjabojA|Generate JUnit test code]]
:[[#_m5EMgCHAEeWLGf5EjabojA|Design]]
::[[#_m-A98SHAEeWLGf5EjabojA|Package Structure]]
::[[#_nBaQMCHAEeWLGf5EjabojA|Class GenerateTestsWorkflow]]
::[[#_nBa3QSHAEeWLGf5EjabojA|Class StateMachineDiagramGenerateTestsWorkflow]]
::[[#_nBcscSHAEeWLGf5EjabojA|Class ClassDiagramGenerateTestsWorkflow]]
::[[#_nBehoSHAEeWLGf5EjabojA|Class CommunicationDiagramGenerateTestsWorkflow]]
::[[#_nBgW0SHAEeWLGf5EjabojA|Class UseCaseDiagramGenerateTestsWorkflow]]
::[[#_nBiMASHAEeWLGf5EjabojA|Class ActivityDiagramGenerateTestsWorkflow]]
::[[#_nBkBMSHAEeWLGf5EjabojA|Class SequenceDiagramGenerateTestsWorkflow]]
::[[#_nBl2YSHAEeWLGf5EjabojA|Class DeploymentDiagramGenerateTestsWorkflow]]
::[[#_nBo5sCHAEeWLGf5EjabojA|Class CompositeStructureDiagramGenerateTestsWorkflow]]
::[[#_nBqu4CHAEeWLGf5EjabojA|Class ComponentDiagramGenerateTestsWorkflow]]
::[[#_nBskESHAEeWLGf5EjabojA|Class TimingDiagramGenerateTestsWorkflow]]
::[[#_nBuZQCHAEeWLGf5EjabojA|Class ProfileDiagramGenerateTestsWorkflow]]
::[[#_nBwOcCHAEeWLGf5EjabojA|Package Behavior]]
::[[#_nC424SHAEeWLGf5EjabojA|Activity Papyrus Test Generation Workflow]]
:[[#_nC6FACHAEeWLGf5EjabojA|Requirements Coverage]]
==<span id="_m2tcESHAEeWLGf5EjabojA">Requirements</span>==
<span id="_m2uqMCHAEeWLGf5EjabojA">- JUnit Generation (id=req01): 
 The framework shall allow to generate JUnit tests for UML diagram editors, its nodes and links</span>
<span id="_m2vRQSHAEeWLGf5EjabojA">- Functional test cases (id=req02): 
 The framework shall test functional test cases: for example creation of elements, hide, delete, edition, drop from model explorer, among many others.</span>
<span id="_m2wfYCHAEeWLGf5EjabojA">- Extensibility (id=req03): 
 The framework shall be extensible with new diagram editors based on GMF, and other technologies where an editor description is available as a model (such as Nattable).</span>
<span id="_m2xGcSHAEeWLGf5EjabojA">- Functional Coverage (id=req04): 
 The framework shall attain complete functional coverage for a diagram editor.</span>
<span id="_m2y7oCHAEeWLGf5EjabojA">- Code Coverage (id=req05): 
 The framework shall cover all the possible code coverable by generated tests (expected to be around 80%)</span>
==<span id="_m20JwCHAEeWLGf5EjabojA">Use Cases</span>==
[[Image:/Users/damus/git/papyrus-mars/tests/framework/org.eclipse.papyrus.tests.framework/doc/imgDOC/UseCasesDiagram.png|UseCasesDiagram]]<br>
<span id="_m483wCHAEeWLGf5EjabojA">As a prerequisite, the tests plug-in must have already been created.  Create tests plug-in, if it doesn't exist already.
As a requirement, following the Papyrus development guidelines an Eclipse plug-in project must be created to contain the tests. Example: org.eclipse.papyrus.uml.diagram.component.tests.
Add a dependency in the plug-in manifest to the test generation framework: org.eclipse.papyrus.tests.framework.</span>
<span id="_m49e0SHAEeWLGf5EjabojA">Example: Generation for the UML Component diagram
Here is an example (ComponentDiagramGenerateTestsWorkflow.xtend):
<pre>
package org.eclipse.papyrus.uml.diagram.component.test.generation

import org.eclipse.emf.mwe2.runtime.workflow.WorkflowContextImpl
import org.eclipse.papyrus.tests.framework.mwe.GenerateTestsWorkflow
import org.eclipse.papyrus.tests.framework.gmfgenuml2utp.GMFGen2UTPModule

class ComponentDiagramGenerateTestsWorkflow {

	def static void main(String[] args) {
		val workflow = new GenerateTestsWorkflow()
		runWorkflow(workflow);
	}

	def static void runWorkflow(GenerateTestsWorkflow workflow) {
        workflow.testProjectName = 'org.eclipse.papyrus.uml.diagram.component.tests'
		workflow.gmfgenUri = workflow.resourceURI('/org.eclipse.papyrus.uml.diagram.component/model/ComponentDiagram.gmfgen')
		workflow.testSrcGenLocation = 'test-gen/'
		workflow.testModel = 'model/ComponentDiagramTest.uml'
		
        workflow.utpModuleFunction = [gmfgen, framework, utp |
            new GMFGen2UTPModule(gmfgen, framework, utp) => [
                diagramTestPackageName = 'org.eclipse.papyrus.uml.diagram.component.test'
                topContainerEditPart = 'PackageEditPart';
                topNodesToTest += #[
                    'PackageEditPart', 
                    'ModelEditPart', 
                    'ComponentEditPart', 
                    'InterfaceEditPart', 
                    'CommentEditPart', 
                    'ConstraintEditPart'
                ]
                childNodesToTest += #[
                    'ModelEditPartCN', 
                    'PackageEditPartCN',
                    'RectangleInterfaceEditPartCN', 
                    'ComponentEditPartCN', 
                    'ComponentEditPartPCN', 
                    'CommentEditPartPCN', 
                    'ConstraintEditPartPCN',
                    'InterfaceEditPartPCN'
                ]
                linksToTest += #[
                    'UsageEditPart',
                    'InterfaceRealizationEditPart',
                    'ManifestationEditPart',
                    'ComponentRealizationEditPart',
                    'AbstractionEditPart',
                    'DependencyEditPart'
                ]
                linksOwnedBySourceToTest += #[
                    'GeneralizationEditPart'
                ]
                
                elementTypesAppearanceTests += #[
                    'PackageEditPart', 
                    'ModelEditPart', 
                    'ComponentEditPart', 
                    'InterfaceEditPart', 
                    'CommentEditPart', 
                    'ConstraintEditPart'
                ]
                elementTypesDropTests += #[
                    'PackageEditPart', 
                    'ModelEditPart', 
                    'ComponentEditPart', 
                    'InterfaceEditPart', 
                    'CommentEditPart', 
                    'ConstraintEditPart'
                ]
            ]
        ]
        
		workflow.run(new WorkflowContextImpl);
	}

}
</pre>
</span>
===<span id="_m4-F4SHAEeWLGf5EjabojA">Papyrus Test Generation Framework</span>===
====<span id="_m4_UACHAEeWLGf5EjabojA">Define list of element edit parts under test</span>====
<span id="_m4_7ESHAEeWLGf5EjabojA">Configure the Guice module for your diagram editor's UTP transformation, detailing the name of the generated package of tests and the desired edit parts to test, as they are described in the gmfgen (See example below). </span>
====<span id="_m5AiISHAEeWLGf5EjabojA">Generate test model</span>====
<span id="_m5BwQCHAEeWLGf5EjabojA">Create the generation launcher (either Xtend-based or Java-based) in an appropiate package, for instance org.eclipse.papyrus.uml.diagram.component.test.generation, in a file such as ComponentDiagramGenerateTestsWorkflow.xtend. Copy the example launcher below and replace with the values for the generation parameters for your own diagram editor. The parameters are:
gmfgenUri: URI for the input GMFGen file
testSrcGenLocation: Folder in the project where the launcher is located where the test code will be generated, for instance test-gen.
utpModuleFunction: injected configuration parameters for the UTP transformation, including tests package name and the various categories of edit-part to test
testModelUri: URI where the UML-UTP intermediate model will be generated. After launching the generation, this model provides an overview of all the generated test artifacts.
Launch the main method as a normal Java class.
The intermediate model and the JUnit code are generated.</span>
====<span id="_m5CXUSHAEeWLGf5EjabojA">Generate JUnit test code</span>====
<span id="_m5C-YSHAEeWLGf5EjabojA">The generated JUnit tests extend the abstract test cases defined in the Papyrus test framework base</span>
==<span id="_m5EMgCHAEeWLGf5EjabojA">Design</span>==
[[Image:/Users/damus/git/papyrus-mars/tests/framework/org.eclipse.papyrus.tests.framework/doc/imgDOC/DesignOverview.png|DesignOverview]]<br>
[[Image:/Users/damus/git/papyrus-mars/tests/framework/org.eclipse.papyrus.tests.framework/doc/imgDOC/GenerationWorkflow.png|GenerationWorkflow]]<br>
<span id="_m7eAQCHAEeWLGf5EjabojA">This is the sequence of actions performed in the workflow to generate the tests. The input and output pins represent the inputs and outputs of every action.
</span>
[[Image:/Users/damus/git/papyrus-mars/tests/framework/org.eclipse.papyrus.tests.framework/doc/imgDOC/ClassDiagram.png|ClassDiagram]]<br>
<span id="_m9_v0SHAEeWLGf5EjabojA">This is the structure of launchers for the generation workflow according to each type of diagram.</span>
===<span id="_m-A98SHAEeWLGf5EjabojA">Package Structure</span>===
[[Image:/Users/damus/git/papyrus-mars/tests/framework/org.eclipse.papyrus.tests.framework/doc/imgDOC/ClassDiagram.png|ClassDiagram]]<br>
====<span id="_nBaQMCHAEeWLGf5EjabojA">Class GenerateTestsWorkflow</span>====
====<span id="_nBa3QSHAEeWLGf5EjabojA">Class StateMachineDiagramGenerateTestsWorkflow</span>====
<span id="_nBcFYSHAEeWLGf5EjabojA">  - specializes [[#_nBaQMCHAEeWLGf5EjabojA|GenerateTestsWorkflow]]</span>
====<span id="_nBcscSHAEeWLGf5EjabojA">Class ClassDiagramGenerateTestsWorkflow</span>====
<span id="_nBd6kCHAEeWLGf5EjabojA">  - specializes [[#_nBaQMCHAEeWLGf5EjabojA|GenerateTestsWorkflow]]</span>
====<span id="_nBehoSHAEeWLGf5EjabojA">Class CommunicationDiagramGenerateTestsWorkflow</span>====
<span id="_nBfvwCHAEeWLGf5EjabojA">  - specializes [[#_nBaQMCHAEeWLGf5EjabojA|GenerateTestsWorkflow]]</span>
====<span id="_nBgW0SHAEeWLGf5EjabojA">Class UseCaseDiagramGenerateTestsWorkflow</span>====
<span id="_nBhk8CHAEeWLGf5EjabojA">  - specializes [[#_nBaQMCHAEeWLGf5EjabojA|GenerateTestsWorkflow]]</span>
====<span id="_nBiMASHAEeWLGf5EjabojA">Class ActivityDiagramGenerateTestsWorkflow</span>====
<span id="_nBjaICHAEeWLGf5EjabojA">  - specializes [[#_nBaQMCHAEeWLGf5EjabojA|GenerateTestsWorkflow]]</span>
====<span id="_nBkBMSHAEeWLGf5EjabojA">Class SequenceDiagramGenerateTestsWorkflow</span>====
<span id="_nBlPUCHAEeWLGf5EjabojA">  - specializes [[#_nBaQMCHAEeWLGf5EjabojA|GenerateTestsWorkflow]]</span>
====<span id="_nBl2YSHAEeWLGf5EjabojA">Class DeploymentDiagramGenerateTestsWorkflow</span>====
<span id="_nBnEgSHAEeWLGf5EjabojA">  - specializes [[#_nBaQMCHAEeWLGf5EjabojA|GenerateTestsWorkflow]]</span>
====<span id="_nBo5sCHAEeWLGf5EjabojA">Class CompositeStructureDiagramGenerateTestsWorkflow</span>====
<span id="_nBpgwSHAEeWLGf5EjabojA">  - specializes [[#_nBaQMCHAEeWLGf5EjabojA|GenerateTestsWorkflow]]</span>
====<span id="_nBqu4CHAEeWLGf5EjabojA">Class ComponentDiagramGenerateTestsWorkflow</span>====
<span id="_nBrV8SHAEeWLGf5EjabojA">  - specializes [[#_nBaQMCHAEeWLGf5EjabojA|GenerateTestsWorkflow]]</span>
====<span id="_nBskESHAEeWLGf5EjabojA">Class TimingDiagramGenerateTestsWorkflow</span>====
<span id="_nBtLISHAEeWLGf5EjabojA">  - specializes [[#_nBaQMCHAEeWLGf5EjabojA|GenerateTestsWorkflow]]</span>
====<span id="_nBuZQCHAEeWLGf5EjabojA">Class ProfileDiagramGenerateTestsWorkflow</span>====
<span id="_nBvAUSHAEeWLGf5EjabojA">  - specializes [[#_nBaQMCHAEeWLGf5EjabojA|GenerateTestsWorkflow]]</span>
===<span id="_nBwOcCHAEeWLGf5EjabojA">Package Behavior</span>===
[[Image:/Users/damus/git/papyrus-mars/tests/framework/org.eclipse.papyrus.tests.framework/doc/imgDOC/GenerationWorkflow.png|GenerationWorkflow]]<br>
====<span id="_nC424SHAEeWLGf5EjabojA">Activity Papyrus Test Generation Workflow</span>====
==<span id="_nC6FACHAEeWLGf5EjabojA">Requirements Coverage</span>==
{| border="1" cellpadding="20" cellspacing="0"
!ID
!Satisfied by
!Verified by
|-
|[[#_m2uqMCHAEeWLGf5EjabojA|req01]]

|
|

|-
|[[#_m2vRQSHAEeWLGf5EjabojA|req02]]

|
|

|-
|[[#_m2wfYCHAEeWLGf5EjabojA|req03]]

|
|

|-
|[[#_m2xGcSHAEeWLGf5EjabojA|req04]]

|
|

|-
|[[#_m2y7oCHAEeWLGf5EjabojA|req05]]

|
|

|}
<span id="_nC6sEiHAEeWLGf5EjabojA">Unsatisfied requirements (5 out of 5) : </span>[[#_m2uqMCHAEeWLGf5EjabojA|req01, ]][[#_m2vRQSHAEeWLGf5EjabojA|req02, ]][[#_m2wfYCHAEeWLGf5EjabojA|req03, ]][[#_m2xGcSHAEeWLGf5EjabojA|req04, ]][[#_m2y7oCHAEeWLGf5EjabojA|req05]]
<span id="_nC7TISHAEeWLGf5EjabojA">Unverified requirements (5 out of 5) : </span>[[#_m2uqMCHAEeWLGf5EjabojA|req01, ]][[#_m2vRQSHAEeWLGf5EjabojA|req02, ]][[#_m2wfYCHAEeWLGf5EjabojA|req03, ]][[#_m2xGcSHAEeWLGf5EjabojA|req04, ]][[#_m2y7oCHAEeWLGf5EjabojA|req05]]

Back to the top