Unit Tests

JUnit Test Plan
 These are the tests that help verify what actions are possible with the goal of being able to measure progress.
 We are using a top-down approach at defining our tests.
 The total number of tests must not be modified but the actual tests can change in explicitness as we progress.
 I’m only listing automatable tests here.
 I greatly encourage defining other regression tests during the development, but they will not be accounted for here.
 We will need discipline creating our Commands. See ReqActionUndoOne
To do:
 These are for all the requirements we must complete. The same work must be done for all other requirements that we choose to
implement.
 This table needs to be reformatted for twiki so that we have three columns: test #, Requirement Name, test definition.
 When ready to implement a test, we will document this table with more detail on the task to be done.
 A tool should be created to generate the code structure. For example, given the table, it should produce code like this:
/**
* Test #1 for requirement ReqCompCompBind
*/
public void testReqCompCompBind1()
{
// TODO: implement
}




We will use this tool once to generate the structure of all our tests. We will comment out those that we can’t yet implement.
When ready to implement them, we will uncomment them.
Keeping the number of tests to implement constant lets us graph out our progress (% of tests implemented, % of tests passing)
The tests listed here are very general; when implemented should try to cover as much code as possible, testing from the highest
level possible.
We have 72 tests for our mandatory requirements.
0 explicit tests.
All Commands must implement execute/redo/undo/canexecute/canundo properly. Usual sequence:
canExecute() ? execute()->redo() and later: canUndo()?undo();
All Commands should leave the model in a valid UCM state. To verify this, the top level class of our
seg.jUCMNav package shall include two methods: testPreConditions(), testPostConditions(). These methods
shall be used in JUnit tests but also in our debug build using assertions. If they aren’t overwritten, these
methods should fail so that we know we have to create them. This will test our model manipulation layer
extensively; higher level tests won’t have to worry about these details but since they will be executed
everytime a command is executed (in debug mode or in JUnit tests), they will be tested VERY often.
testPreConditions(): will check the model to see if it is valid to call redo(). This can involve calling canExecute()
but its main goal is to check that if a redo has already been called, followed by undo, the model is back in its
initial state. Should verify that newly created elements are not in the model, etc. Should be the first line
executed in redo() and last in undo().
Req Action Undo One
testPostConditions(): will check the model to see if it is valid after the execution of the command. This usually
involves checking to see if the newly created elements are actually in the model, that removed ones are no
longer in it, that PathNodes have appropriate in/out connections. Should be the last line executed in redo()
and first in undo().
2 explicit tests.
Requirement concerns both ComponentElement and ComponentREf
1) Creation scenario:
ComponentRef must be in palette.
When put on content pane, must be added to the model.
Must always be linked to a ComponentElement
2) Edition scenarios:
Properties view must show x,y,id,name,width,height, compDef:
EObjectPropertySource.addPropertyToDescriptor(Collection descriptors, EAttribute attr, EClass c) must
modify descriptors.
Req Comp
X,y,width,height
MapAndPathGraphXYLayoutEditPolicy.createChangeConstraintCommand(EditPart child, Object constraint)
shall create a command. If fixed should not be able to move or resize.
2 explicit tests
1) When a component is moved inside another, parent is set.
2) Properties view must show parent
EObjectPropertySource.addPropertyToDescriptor(Collection descriptors, EAttribute attr, EClass c) must
modify descriptors. Should see dropdown of possible componentrefs.
Req Comp Comp Bind
2 explicit tests
1) When a component is moved outside its parent, parent is unset.
2) Properties view must show parent
EObjectPropertySource.addPropertyToDescriptor(Collection descriptors, EAttribute attr, EClass c) must
modify descriptors. Should have a none option in the componentrefs dropdown list.
Req Comp Comp Unbind
2 explicit tests.
1) When a PathNode is moved inside a ComponentRef, parent is set.
2) Properties view must show parent
EObjectPropertySource.addPropertyToDescriptor(Collection descriptors, EAttribute attr, EClass c) must
modify descriptors. Should see dropdown of possible componentrefs.
Req Comp Path Bind
2 explicit tests.
1) When a PathNode is moved outside its parent, parent is unset.
Req Comp Path Unbind
Req Connections
2) Properties view must show parent
EObjectPropertySource.addPropertyToDescriptor(Collection descriptors, EAttribute attr, EClass c) must
modify descriptors. Should have a none option in the componentrefs dropdown list.
3 explicit tests.
1) When end and start/wait/timer are selected, connect appears in the contextual menu.
2) Connect element overlaps others, disconnect appears in contextual menu.
3) Connect command moves two selected elements.
Req Elem And Fork
3 explicit tests.
1) Appears in palette and can be inserted on path. Adds a second outgoing path.
2) Appears in PathNode contextual menu, adds a second path
3) Appears in contextual meunu, when EmptyNode and StartPoint are selected; doesn’t add a path,
removes the start point.
3 explicit tests.
1) Appears in palette and can be inserted on path. Adds a second incoming path.
2) Appears in PathNode contextual menu, adds a second path
3) Appears in contextual meunu, when EmptyNode and EndPoint are selected; doesn’t add a path,
removes the end point.
Req Elem And Join
5 explicit tests.
1) Can delete any PathNode that have exactly 1 input, 1 output at any time.
2) Can downgrade a PathNode that have exactly 1in, 1 out at any time to an EmptyNode.
3) Can delete componentrefs at any time, can delete components and all their references at any time.
4) For all PathNodes that have multiple inputs or outputs, deleting all elements on the optional inputs or
outputs removes the optional paths. (Forks/joins are transformed into EmptyNodes)
5) Deletion of completely selected paths is possible.
Req Elem Delete
Req Elem Direction Arrow
2 explicit tests.
1) Appears in palette and can be inserted on path.
2) Is oriented properly
2 explicit tests.
1) Appears in palette and can be inserted on path. Replaces EmptyNode if placed on one.
2) Can “consume” start/end points; when dragged on them, they are linked.
Req Elem Dynamic Stub
2 explicit tests.
1) Appears in palette and can be inserted on path.
2) To be used as test subject for edit/movement of PathNodes.
Properties view must show x,y,id,name
EObjectPropertySource.addPropertyToDescriptor(Collection descriptors, EAttribute attr, EClass c) must
modify descriptors.
Req Elem Empty Point
X,y
MapAndPathGraphXYLayoutEditPolicy.createChangeConstraintCommand(EditPart child, Object constraint)
shall create a command.
3 explicit tests
1) Path tool exists in palette and can be inserted onto path
2) Start/End points can be merged.
3) Can have guard condition
Req Elem End Point
3 explicit tests.
1) Appears in palette and can be inserted on path. Adds a second outgoing path.
2) Appears in PathNode contextual menu, adds a second path
3) Appears in contextual meunu, when EmptyNode and StartPoint are selected; doesn’t add a path.
Req Elem Or Fork
4 explicit tests.
1) Appears in palette and can be inserted on path. Adds a second incoming path.
2) Appears in PathNode contextual menu, adds a second path
3) Appears in contextual meunu, when EmptyNode and EndPoint are selected; doesn’t add a path,
removes the end point.
4) Can have guard condition
Req Elem Or Join
Req Elem Responsibility
2 explicit tests.
1) Responsibility tool exists in palette and can be inserted into diagram
2) Must always be linked to Responsibility. Properties view should show Responsibility dropdown.
3)
2 explicit test.
1) Path tool exists in palette and can be inserted onto path.
2) Can have guard conditions
Req Elem Start Point
1 explicit test.
1) Properties view shows workload attribute
Req Elem Start Point Attributes
2 explicit tests.
1) Appears in palette and can be inserted on path. Replaces EmptyNode if placed on one.
2) Can “consume” start/end points; when dragged on them, they are linked.
Req Elem Static Stub
6 explicit tests.
1)
2)
3)
4)
5)
6)
Req Elem Stub Actions
Req Elem Timer
2 explicit tests.
Must be able to create plugin.
 creates a new map
 positions editor at a new navigationlocation
 from contextual menu
 from views
must be able to view plugin
 double click in editor
 from views
 positions editor at a new navigationlocation
add plug-in
 if static and has no plug-ins, must be able to select maps from a list of
possibilities
 if dynamic, should be able to add a map from a list of possibilities to a list of
plugins
 during execution, stub binding conditions are examined to know which plug-in
to be used
remove plugin
 inverse of previous operations
rename plugin
 a plugin is just another map.
bind plugin
 wizard or property page
 activated by contextual menu on stub
 select a plugin
 match stub inputs with plugin start points
 match stub outputs with plugin end points
 numbers do not need to match
Req Elem Wait
1) Timer appears in palette and can be inserted into diagram
2) Contextual menu allows for the creation of a timeout path.
2 explicit tests
1) Wait appears in palette and can be inserted onto path
2) can have guard condition
3 explicit test
1) Appears in file/export
2) Appears in contextual menu of a diagram in package explorer
3) can have guard condition
Req Export Bitmap
1 explicit test
1) help about exists
1 implicit
Daniel finds it sufficient.
Req Help About
1 explicit test
1) online help exists
1 implicit
Daniel finds it sufficient.
Req Help On Line
Req Open
Req Save
Req Save As
Req Save Backup
Req Select All
Req Select Group
Req Select Group Delete
Req Select Group Move
Req Select Single
Req Select Unselect All
Req Select Unselect One
Req Browse History
1 explicit test
1) top level model element is URNSpec
1 explicit test
1) top level model element is URNSpec
0 explicit tests
Supported by framework; implicit if ReqSave is done.
1 explicit test
1) UCM Editor supports Team Support for Local History purposes.
0 explicit tests.
0 explicit tests.
0 explicit tests. See ReqElemDelete
0 explicit tests.
0 explicit tests.
0 explicit tests.
0 explicit tests.
1 explicit test
Req Browse Model
Req Labels
Req Select Feedback
Req Documentation
Req Java Version
1) Navigation Location implemented for all diagrams in one UCM
4 explicit tests
1) Outline view is implemented properly
2) Explorer is implemented properly (remember to be able to rename map)
3) Responsibilities view is implemented properly
4) Description view is implemented properly
2 explicit tests
1) Contextual menu on ComponentRef/PathNode shows show/hide label
2) Properties view must show label
EObjectPropertySource.addPropertyToDescriptor(Collection descriptors, EAttribute attr, EClass c) must
modify descriptors.
0 explicit tests.
0 explicit tests.
0 explicit tests.
If it builds, it runs.