FlexUnit4: [Test(expect=“Error”)] doesn't catch errors?
-
18-09-2019 - |
Question
The following code produces a failed test, not a passing test (as I would expect):
[Test(expects="Error")]
public function someTest():void {
throw Error("this test doesn't pass");
}
Solution
In older versions it was [Test(expected='')]
In newer versions we support both expected and expects as this was confusing for many
OTHER TIPS
Make sure you're linking against the release SWC of FlexUnit, or if you're compiling it yourself, make sure you're using --keep-as3-metadata+=Test in the "additional compiler options" box in project properties.
I think the problem may have been that I was using an older version of FlexUnit4. I just upgraded (to 4.0 RC1) and it seems to be working now.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow