Membru cu cele mai relevante răspunsuri
I would like to create a machine with two instances of my adapter class and call its methods f() and g() in sequence for each instance. In addition, I would like to have interleaving of f() and g() with respective object instances
I tried something like this:
new MyAdapter();_.f();_.g() ||| new MyAdapter();_.f();_.g()
but the output is not what I am after.
How would I let SpecExplorer generate something like this:
adapter1.g();4 iulie 2012 04:10
You are not composing the sceanrio from left with a model. This is the usual usage.
Assuming that you just left this away here is a machine you might be looking for:
machine TwoThreadScenario2() : Main
new ComplexThread; new ComplexThread; ((_.f;_.g))
machine SlicedThreadModelProgram() : Main
TwoThreadScenario2 || ThreadModelProgram
Hope it helps5 iulie 2012 12:45
Thanks for your reply. I should have put the model program in my example. I also tried your example. But I have one condition that g() should be called only after f() is called for each instance. What happens is that this machine creates two ComplexThread instances and calls f() on one instance and g() on another instance. I want to avoid this interleaving. Is it possible in Spec Explorer?
5 iulie 2012 13:24
- Editat de Dharma11 5 iulie 2012 13:26
ok, if you need more control from the scenario, you can use the let-statement like this:
Hope this can solve your problem5 iulie 2012 13:47
I have an instance-based model and trying to generate tests with two instances of the class under test. For example, I place my machines below. I am not sure whether there are other (good) ways to use Spec Explorer for testing with multiple instances.
The reason I am asking is that sometimes I want to interleave all actions with two (or more) instances. My machine below used the "|||" operator for this purpose. But the only difference in the operands is the instance id. Just curious how this situation is typically handled in Spec Explorer.// Test Scenario: Connect and Disconnect on Two instances
machine TwoInstancesConnectDisconnectScenario() : Main where ForExploration = false
let SoftwareBusAdapterImpl conn, SoftwareBusAdapterImpl conn2 in
(new conn.SoftwareBusAdapterImpl;conn.Create;(conn.Connect & conn.Disconnect);conn.Destroy)
(new conn2.SoftwareBusAdapterImpl;conn2.Create;(conn2.Connect & conn2.Disconnect);conn2.Destroy)
machine TwoInstancesConnectDisconnectProgram() : Main where ForExploration = true
(TwoInstancesConnectDisconnectScenario;exit) || ModelProgram
machine TwoInstancesConnectDisconnectTestSuite() : Main where TestEnabled = true
construct test cases where strategy = "shorttests" for TwoInstancesConnectDisconnectProgram()
}12 iulie 2012 18:12
If you model open systems (dynamic creation/annihilation of state objects),
instance based modeling is perfect due to it's elegant control via cord.
Using scenarios/embedded code you can fully control your exploration reading/writing states, reading/writing in/out parameters, control temporal properties etc.
If you like, you can rewrite your code like this:
machine OneInstancesConnectDisconnectScenario(SoftwareBusAdapterImpl conn) : Main
(conn.Connect & conn.Disconnect);
machine TwoInstancesConnectDisconnectScenario() : Main
let SoftwareBusAdapterImpl conn,
SoftwareBusAdapterImpl conn2 in
Hope this helps.13 iulie 2012 08:09
Thanks. Suppose we want to scale-up the above machine for several connections (e.g, 100), is there a way to compactly specify in Cord? By compact I mean not explicitly enumerating machines and scenarios for 1, 2, 3, ... connections. This feature will help to validate performance and timing problems with the SUT.
Dharma21 iulie 2012 16:50