Skip to content

Instantly share code, notes, and snippets.

@neilmanuell
Forked from alecmce/two-asserts-in-test.as
Created June 1, 2011 16:00
Show Gist options
  • Save neilmanuell/1002629 to your computer and use it in GitHub Desktop.
Save neilmanuell/1002629 to your computer and use it in GitHub Desktop.
I don't understand why one assert per test is superior
// the code
class eg
{
public var width:int;
public var height:int;
public function eg(width:int, height:int)
{
this.width = width;
this.height = height;
}
public function clone():eg
{
return new eg(width, height);
}
}
// the test
[Test]
public function a_clone_is_the_same_width_as_its_parent():void
{
a = new eg(123, 321);
b = a.clone();
assertEquals(a.width, b.width);
}
[Test]
public function a_clone_is_the_same_height_as_its_parent():void
{
a = new eg(123, 321);
b = a.clone();
assertEquals(a.height, b.height);
}
@neilmanuell
Copy link
Author

now if one fails, the tests name will tell you which one with out having to write fail messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment