0

I'm new using test in xcode and getting trouble using it. I'm trying to use xctest for my application, but all tests pass. Even those that must fail. After clean and build the project again it remains passing all the tests, e. g:

-(void)testIfFails
{   
    XCTAssertTrue(NO);
}

The test above succeeds in my project. Can anyone explain me how it works right, or if I`m doing it the wrong way?

Shubhank
  • 21,721
  • 8
  • 65
  • 83
André Muniz
  • 708
  • 2
  • 8
  • 17
  • how do you start your tests? This code should fail, as expected. – lootsch Mar 19 '14 at 19:21
  • I go to test navigator and then click run. Running all or single tests give me the same results. – André Muniz Mar 19 '14 at 19:23
  • interesting... http://cl.ly/image/2o041v2c2v11 – lootsch Mar 19 '14 at 19:27
  • 1
    Put a breakpoint in your test. It seems likely that none of them are being run, which would count as a pass. – jrturton Mar 19 '14 at 19:50
  • See this issue: [xcode-5-says-tests-failed-but-shows-green-checkmarks][1] Bug in Xcode and corrected in version 5.1 [1]: http://stackoverflow.com/questions/19233626/xcode-5-says-tests-failed-but-shows-green-checkmarks/23638201#23638201 – HackaZach May 13 '14 at 17:49

2 Answers2

0

This is definitely one of those moments when Xcode goes crazy.

Try one of the following:

  1. Product -> Clean
  2. Holding ALT pressed Product -> Clean Build Folder
  3. Window -> Organizer -> Projects -> Select Your Project - > Delete Derived data
  4. Close Xcode, Restart Computer (it once worked for me).
  5. Mess up with the test routine code. Maybe Xcode cached something.

If nothing works, you should report a bug: https://bugreport.apple.com/

Ilea Cristian
  • 5,741
  • 1
  • 23
  • 37
0

Resolved the issue. The tests target I was using is the default we have when create the project. Before testing, I migrated from OCUnit to XCTest and then began my work. Nothing made the tests run correctly. After trying all the suggestions I got, I decided to create a new test target and had it working in the first try. Hope it help anyone.

André Muniz
  • 708
  • 2
  • 8
  • 17