SirRupertIII
SirRupertIII

Reputation: 12596

SenTestingKit setUp and tearDown overrides get called twice

I am using KIF to test our iOS app. I am trying to make some tests that will go before and after my whole test sweet. I made a SenTestSuite category and overrode -setUp and -tearDown:

 -(void)setUp
 {
     [tester loginCurrentVersion];
     NSLog(@"setup");
 }

 -(void)tearDown
 {
     [tester logoutFromAnywhereIfNeeded];

     NSLog(@"teardown");
 }

These methods do get called, but my problem is that they both get called twice. I can't access any of the SenTestSuite.m methods. I am unsure why they are getting called twice. Why is it doing this and how can I solve this?

Thanks!!

Upvotes: 0

Views: 300

Answers (2)

kuglisb
kuglisb

Reputation: 141

Since you are using KIF, your setUp and tearDown methods should be the beforeAll and afterAll. I also suggest you to take a look at the sample application and try to understand those tests.

Upvotes: 0

Jon Reid
Jon Reid

Reputation: 20980

Using a category to override a class's methods is really, really iffy. Instead, subclass SenTestCase and put your -setUp and -tearDown there. Then have your test classes inherit from it.

Upvotes: 2

Related Questions