Can I put an "expects" on a Theory?
I have a set of tests that want to be run across the cross-product of two data sets.
I have successfully got all the positive tests running using Theory, but the negative tests are reporting a failure without explaining the failure. I suspect that the problem is that the Theory package doesn't play well with the "expects" metadata parameter.
This is what I'm doing (with the variable names and data replaced by nonsensitive ones). The actual theory involves two data types, but when this problem showed up I duplicated it with just the strings. Of these three theory tests, the first two succeed but the third fails with a backtrace and no failure description:
// The space of operation types across which the Theory test will run.
[DataPoints]
[ArrayElementType("String")]
public static var mAllPatterns:Array = ["foo", "bar", "baz", "qux", "quux"];
// The list of operations that apply to all cases
private var mUniversalPatterns:Array = ["qux", "quux"];
[Theory(description="Smoke test with strings")]
public function positiveSmoke1(thing:String):void
{
// We are a happy clam
}
[Theory(description="Smoke test with strings and assumethat")]
public function positiveSmoke2(thing:String):void
{
Assume.assumeThat(thing, inArray(mUniversalPatterns));
// We are still a happy clam
}
[Theory(description="Negative smoke test with strings and assumethat", expects="flash.errors.EOFError")]
public function negativeSmoke(thing:String):void
{
Assume.assumeThat(thing, inArray(mUniversalPatterns));
// We are an unhappy camper
throw new EOFError("Expected failure");
}
The output looks like this:
BasicTests.negativeSmoke .
BasicTests.negativeSmoke F
BasicTests.positiveSmoke1 .
BasicTests.positiveSmoke2 .
Time: 0.04
There was 1 failure:
1 BasicTests.negativeSmoke Error: negativeSmoke mAllPatterns[3]
at org.flexunit.experimental.runners.statements::TheoryAnchor/http://www.adobe.com/2009/flexunit/classInternal::reportParameterizedError()
at org.flexunit.experimental.runners.statements::MethodCompleteWithParamsStatement/evaluate()
at org.flexunit.internals.runners.statements::StackAndFrameManagement/evaluate()
at org.flexunit.experimental.runners.statements::TheoryBlockRunnerStatement/evaluate()
at org.flexunit.experimental.runners.statements::AssignmentSequencer/runWithCompleteAssignment()
at org.flexunit.experimental.runners.statements::AssignmentSequencer/evaluate()
at org.flexunit.experimental.runners.statements::AssignmentSequencer/handleChildExecuteComplete()
at org.flexunit.token::AsyncTestToken/sendResult()
at org.flexunit.internals.runners.statements::AsyncStatementBase/sendComplete()
at org.flexunit.experimental.runners.statements::AssignmentSequencer/sendComplete()
at org.flexunit.experimental.runners.statements::AssignmentSequencer/handleChildExecuteComplete()
at org.flexunit.token::AsyncTestToken/sendResult()
at org.flexunit.internals.runners.statements::AsyncStatementBase/sendComplete()
at org.flexunit.experimental.runners.statements::TheoryBlockRunnerStatement/handleChildExecuteComplete()
at org.flexunit.token::AsyncTestToken/sendResult()
(and on for many levels of stack, all inside FlexUnit)
