Test NoDoubleInit still failing in 3.0 unit tests

Test NoDoubleInit still failing in 3.0 unit tests

Old forum URL: forums.lhotka.net/forums/t/3355.aspx


marklindell posted on Thursday, August 09, 2007

This relates to an old post that was never resolved here.

The reason this test is failing is due to test unit tests having a dependency on the order they are run which was not intended.  If your run the test StringRequired() followed by NoDoubleInit(), NoDoubleInit() will fail.

The reason is that the class level business rules method HasPerTypeRules.AddBusinessRules() will have already been called once and will not be called again so the GlobalContext["Shared"] will not be incremented.

Rather than trying to clear the internal static state in CSLA, I simply created another HasPerTypeRules2 class and changed it out in the NoDoubleInit() test method.

Hope this answer the original post.

Mark Lindell

marklindell replied on Thursday, August 09, 2007

As a follow up a similar situation is occuring with AppDomainTestIsCalled().  it fails when executed after one of the AppContextTests due to the Global context all ready containing a key that is re-used.  The solution to this one is simply to clear the GlobalContext at the beginning of the test.

Boy, I'm glad I'm testing the tests....

RockfordLhotka replied on Thursday, August 09, 2007

marklindell:

Boy, I'm glad I'm testing the tests....

So am I, thanks for the help!

I run the tests as a batch, so they always run in a consistent order (apparently), so I've never encountered any of the reported issues...

Copyright (c) Marimer LLC