I am currently evaluating Spec Explorer, but I am stuck with a problem concerning abstract specifications of function behaviour. I have something like :
[TypeBinding("Implementation.ImplementationElement")]
public class ModelElement
{ /*... */ }
public class ModelBehaviour
{
[Rule]
public static void doSomething()
{
ModelElement sel = SelectElement(elements);
// ... do something with sel
}
private static Set<ModelElement> elements = new Set<ModelElement>();
}
Now I do not want to define SelectElement(Set<ModelElement> e)
explicitly in the model program. I would prefer to specify it with a postcondition like elements.contains(\result);
. Is this somehow possible ?
The problem with the explicit definition is that I would enforce a selection strategy.
I tried to avoid the problem in the following way (maybe I am just missing something small and someone could give me a hint to do it correctly):
- Add a parameter
ModelElement e
todoSomething
- Add condition
Condition.IsTrue(elements.Contains(e))
todoSomething
- Define an action in the config-script
SelectElement
Define a machine
SelectAndDo
in the config-Script as follows:machine SelectAndDo() : Main { let ImplementationElement e Where {.Condition.IsTrue(e.Equals(SelectElement()));.} in doSomething(e) }
- Use
SelectAndDo
instead ofdoSomething
However, this does not work, because the exploration of the corresponding model enters an error state. If this does not work at all, is there a good alternative to Spec Explorer on Windows, preferably stable? Can FsCheck be recommended for testing stateful systems?