Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

GHAssertEquals not triggering failure. #109

drekka opened this Issue Jan 8, 2013 · 4 comments


None yet
3 participants

drekka commented Jan 8, 2013

I've got something really weird going on. I have a test with this in it:

GHAssertEquals(self.testViewController.selectedRow, (NSInteger) 5, @"an error");

The value of selectedRow is 0, so I see this in the log:

Name: GHTestFailureException
File: /Users/d4rkf1br3/projects/Simon/Simon tests/SIUIApplication_ActionsTests.m
Line: 45
Reason: '0' should be equal to '5'. an error

BUT... GHUnit thinks the test has passed successful, not flagging the error or marking the test in red.

But if I add a GHFail() or GHAssertNil(), etc. The test fails as expected.

drekka commented Jan 8, 2013

I reverted back to the 0.5.6 build of GHUnit and it seems to be working again. Had a quick look at the differences and I could not see anything obvious that would effect this assert. The only thing I can think of as a possibility is a threading issue. But I'm not sure about that.

dak12 commented May 3, 2013

Hi drekka

I am still facing this issue.

I have XCode 4.6.1 and have GHUnit 0.5.6.

There is a simple test to verify addition of 2 numbers. But I always see the test passing even if its supposed to fail.

Here is the test

  • (int)sumA:(int)a B:(int)b
    return a + b;

  • (void)testsumAB
    int a = 2;
    int b = 3;

    NSLog(@" a + B = %x", [self sumA:a B:b]);
    GHAssertEquals([self sumA:a B:b], (a+b+1) , @"sumA:B: should return the sum of a+b");

In above test method should return 5 and we are comparing it with 6. Hence test should fail.

Any idea

drekka commented May 9, 2013

Sorry I have not checked if I'm still getting it. I'm still using 5.6.


x2on commented Nov 3, 2013

I checked it with 0.5.8 and it works like expected:

2013-11-03 22:52:46.327 Tests[61267:70b] Issue109Test/testsumAB ✘ 0.00s
2013-11-03 22:52:47.655 Tests[61267:70b] Re-running: Issue109Test/testsumAB <GHTest: 0x8b47220>
2013-11-03 22:52:47.656 Tests[61267:70b]  a + B = 5
2013-11-03 22:52:47.659 Tests[61267:70b] 
    Name: GHTestFailureException
    File: /Users/x2on/gh-unit/Examples/MyTestable-iOS/Tests/Issue109Test.m
    Line: 39
    Reason: '5' should be equal to '6'. sumA:B: should return the sum of a+b

@x2on x2on closed this Nov 3, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment