Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertNotEquals() method in Assert #38

Closed
jottinger opened this issue Mar 25, 2011 · 2 comments
Closed

assertNotEquals() method in Assert #38

jottinger opened this issue Mar 25, 2011 · 2 comments

Comments

@jottinger
Copy link

assertEquals() should have an analog that asserts inequality. There's precedent with assertSame() and assertNotSame(); you should be able to likewise assert that two values are NOT equal to each other.

@jottinger
Copy link
Author

I'd be more than happy to write some code for this, but I have a question: What's an acceptable style?

The first thing that comes to mind is copying the assertEquals() code, inverting it. But that's a ton of code. It's not difficult, it's just something to track.

The second thing - and the one that appeals most to me - is writing assertNotEquals in this mode:

assertNotEquals(object1, object2) {
try { assertEquals(object1, object2); } catch(AssertionFailure af) { fail(); }
}

What this does is obvious, but I don't know if using the exception mechanism that way is acceptable for the TestNG project.

I don't mind writing a patch, if the assertNotEquals() makes sense for everyone else, but I don't want to write a patch that's not acceptable.

@cbeust
Copy link
Collaborator

cbeust commented Mar 25, 2011

I just added these methods to the Assert class, can you try them? You can download the beta at http://testng.org/beta

I just copy/pasted the ones that someone just submitted to

http://jira.opensymphony.com/browse/TESTNG-266

Interesting timing between you and Patrick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants