Hi folks,

I came across an interesting bug yesterday and during investigation
found that there was a very comprehensive test that covered the situation.

The problem is that the asserts were not actually running.

The asserts were inside a loop where the expectation was that the loop
would run exactly once as a previous call returned an array of items
with one value in it.

Except it didn't.

It returned an empty list.

So, if you see something like this, a simple line like:

  c.Assert(someList, gc.HasLen, 1)

Is sufficient to have caught this particular issue.


Remember a key step when writing tests is to have the test fail first,
then make it pass.

One trick I use is to assert checks against data I know is wrong. If the
test passes then I know I have other problems.

Tim

-- 
Juju-dev mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju-dev

Reply via email to