Pattern: this test assertion pattern is about properties that are to be verified on some artifact, in a predicative way. For example, in a specification requirement like: the document D must be valid against the XML schema S, D is the artifact under test, and the predicate is "validating against S". The TA can be represented by a predicative assertion P(x), here: Validate-against-Schema-S(Doc) that has a boolean value: true or false. No attempt is made to describe the operational side of the verification (e.g. how or under which conditions the document D is obtained from the test environment). But the "type" of artifact subject to the TA, is identified (e.g. a PurchaseRequest document, a SOAP Body element).
Comments:
- such a test assertion pattern is almost indistinguishable from the related specification requirement... it could be extended with a behavioral component: "when the SUT generates a document D..."
- such a TA usually assumes an implicit qualifier, in order to qualify the artifacts to which it applies. E.g the document must be of a certain type, must be produced under certain conditions, etc.
Example of TA: assertion BP2010 in Test Assertion Documents for WS-I profiles: "for a wsdl:portType definition, the "name" attributes of Operation elements are unique in the wsdl:portType definition".
- qualifier of artifact under test: wsdl:portType element in a WSDL file
- predicate: the "name" attributes of Operation elements are unique in the artifact.
Variant: the implicative variant: Q(x) => P(x), or "if property Q is verified on the artifact X, then property P must be verified on X". The TA only concerns artifacts that verify Q in the first place (if (Q(x) is false, the TA does not apply to x). The predicate Q(x) can be seen as a generalization of the TA qualifier previously mentioned. The conditional part (predicate Q) may have different names (e.g. "context" in WS-I, "pre-condition" in IIC TestFramework ). The conclusion part (predicate P) also ("assertion description" in WS-I, "assertion" in IIC TestFramework).
NOTES:
- in above abstractions, P(x) and Q(x) could themselves be more complex logical expressions, e.g. P(x) can be of the form: P1(x) AND P2(x) (see below).
- A same TA can often be modeled either in a predicative form with qualifier (for every artifact X of type T, the property P is verified) or in an implicative form (if artifact X verifies: being of type T, then it must also verify P).
Examples: almost all test assertions in the WS-I basic profile are of the predicative kind, and many are worded as implicative: (see link Test Assertion Documents for WS-I profiles (2003-2005) in section.
Example of Implicative TA: assertion BP2020 in Test Assertion Documents for WS-I profiles: "for a wsdl:binding element, if the style attribute of the contained soapbind:binding is "rpc" and the use attribute is "literal", then the namespace attribute is specified on all soapbind:body elements and the value of the namespace attribute is an absolute URI."
- type of artifact under test: wsdl:binding element in a WSDL file
- condition: (style attribute in soapbind:binding has value "rpc") AND (use attribute has value "literal")
- conclusion: (namespace attribute is specified on all soapbind:body elements) AND (the value of the namespace attribute is an absolute URI)
<serm> What is the relationship between the two? Does event-behavior model subsume the predicative model or vice versa or they are equivalent? Manually, I think it looks like the same test case can be expressed in either model, so they are just different flavors? For example, in the example above the event is "when an MSH sends a message", condition is "binding mode is rpc", action is "the message is sent with (style attribute in soapbind:binding has value "rpc") AND (use attribute has value "literal") AND (namespace attribute is specified on all soapbind:body elements) AND (the value of the namespace attribute is an absolute URI) ".
<jacques> Serm: you may be right - I am aware that the distinction I establish here is often (always?) just a modeling choice. I am not claiming that my classification is final, rather this is a starting point. Maybe we can unify these patterns. I think that the predicative approach is quite intuitive when the spec requirement is about a property that an artifact must satisfy (case for specs that concern documents). But it could be contrived when the TA is mostly about behaviors and events. For example, in the rule-based area people have introduced the notion of "event-condition-action" rules, in spite of the fact that all rules could technically be expressed in form of predicates and logical expressions. But the ECA model is more intuitive and helps users, for a type of rules.
<serm>The examples Jacques gave in the event-behavior is so easily stated with the predicative model (actually in the Example 2, I would move the ""type" attribute not set, and with a Service element content that is not a URI" to the condition field). Of course, we can easily omit the event part, then the event-behavior model is so similar to the predicative model. OTOH, an assertion like the NDR has no event part at all if we think that what is being tested is just a schema (artifact) but if we think that we are test the software that generates schema then there can be event. The event-behavior model seems to give a little more info about what needs to be done to trigger the test.
<jacques> we could always model an event in predicative form so that any combination of event(s) + condition(s) appears in pure predicative form (e.g.: "receiving(messagehandler, messageA) AND absent_from(messageA, elementX)"). The value of distinguishing notions such as events, is just a help in the modeling process, and the TA formulation may be simplified. Also, for test case writers: more intuitive. An event is often associated with some operation occurring on the test environment. In turn, that assumes some level of modeling of the test env itself (not just the SUT), e.g. the SUT is (or contains) a message handler, the TA may assume that it supports operations "handler.receive()" and "handler.send()". Given these, events can be formally defined: ev1 = handlerX.receive(messageA). So far, not much difference with predicative notation. But where predicative notation is weak, is when there is state transition over time. E.g., you want to express a state change "if SUT is in state A, then if event X occurs it must now be in state B". You cannot just say "SUT_state_is(A) and occurs_event(X, SUT) and SUT_state_is(B)" this would not make sense, due to lack of rendering of the state change over time. (I know there has been some "temporal logic" formalisms but I'd prefer to look into something simpler, more intuitive first...)
<serm> Since there is no constraint on predicate, I can also create a transition predicate to handle this temporal relationship. Valid_Transition(A, X, B). In light of this, the ECA model may be more grounded and better.
<Jacques>ECA would be more intuitive and less contrived, when the TA describes a SUT state transition. Although each state could be described by predicates, e.g. something close to what OCL does.
<serm> This brings me to another question to whether the TAG can recommend the perspective which the TA should be written from - from the testbed/testing partner or purely from the SUT perspective or both need to be used? Maybe the right question is what is the scope of the TA, what are in the purview of the TA? Maybe a discussion around this can make TA convention more uniform.
<jacques> Ah.. the interesting questions start coming out... My feeling is that this depends on the spec: for specs that prescribe "behaviors" of systems (and not just properties on artifacts produced by these systems), its hard to make abstraction of teh operational aspect of the SUT, and therefore the TA should be aware and make use of "operations" on such SUTs. That means such TAs would be written with some idea of what the test harness would look like (and assume that some part of the harness will activate the operation). But I would still try to make abstraction of which test harness component is activating this operation, especially if it is outside the conformance target (i.e. not part of the implementation under test). E.g. I would not state a TA like: "If the test driver sends a message X to the IUT, then..." but rather "if the IUT receives message X then ..."
<serm> We should document this in the guideline if we agree that this is sufficient - "TA should be written around the target conformance abstracting out related components outside the conformance target." I think another example could be "if the IUT receives message X and the message X is rejected by an external component, then the IUT sends a negative read ack"......Can this TA be wriiten without mentioning the "external component" since it is not a target conformance or "external component" is abstract enough?
TAG Wiki