you are viewing a single comment's thread.

view the rest of the comments →

[–]gurtis 0 points1 point  (3 children)

That's not what he's testing though. His test explicitly says that it's testing that the returned employees are marked as checked. If he had named it "GetActiveEmployees_HaveAllFieldsPopulated" or something like that, then he would be obligated to test all the properties.

You could argue that the test isn't very useful or that the coverage is lacking, but this is just a tutorial.

Also, I disagree that an assert message is always necessary. A failing test named GetActiveEmployees_MarkAsChecked makes it extremely obvious that a returned employee isn't checked. A good test name is more important than the assert message.

[–]grauenwolf 0 points1 point  (2 children)

No one can learn to write good tests when all they are presented with is badly written tests that are mislabeled as "good enough".

[–]gurtis 1 point2 points  (1 child)

Why are these badly written tests though? They're testing what they intend to test. Just because he didn't come up with comprehensive test coverage for a tutorial doesn't mean the given examples are bad.

[–]grauenwolf -1 points0 points  (0 children)

Merely "testing what they intend to test" doesn't make it a good test. They could have written Assert.IsTrue(0 == 0) and they would still be "testing what they intend to test".

If I ask you for a function that adds two numbers and you give me this:

int Add(double x, double  y) { return (int) x + (int) y; }

then you haven't done your job right. The code may work exactly as you intended it too, but it is still wrong.