Coder Social home page Coder Social logo

assertNotEquals about junit4 HOT 9 CLOSED

junit-team avatar junit-team commented on August 22, 2024
assertNotEquals

from junit4.

Comments (9)

bloritsch avatar bloritsch commented on August 22, 2024

With Hamcrest, this is possible. It would look like:

assertThat( 1, not( equalTo(5) ) );

I have found that this is useful more often than you might originally think.

from junit4.

trenton avatar trenton commented on August 22, 2024

Agreed. Use assertThat instead of assertEquals and the "older" asserts supplied by JUnit directly.

from junit4.

dsaff avatar dsaff commented on August 22, 2024

Looks resolved.

from junit4.

dsaff avatar dsaff commented on August 22, 2024

Re-requested in http://twitter.com/#!/KevlinHenney/status/96329124712415232

from junit4.

detinho avatar detinho commented on August 22, 2024

I added assertNotEquals to Object, long and double. For which branch should I send my pull request?

from junit4.

dsaff avatar dsaff commented on August 22, 2024

Marcus,

It would be against 4.10. Truth be told, I'm still not 100% sold on the functionality...

from junit4.

kcooney avatar kcooney commented on August 22, 2024

If these are added, I personally think the method names should be assertNotEqual. "x equals y but y does not equal z"

In any case, could someone please provide a concrete use case where assertNotEqual(long, long) would be useful?

from junit4.

dsaff avatar dsaff commented on August 22, 2024

@kcooney, I think assertNotEquals is less surprising. We already have assertNull/assertNotNull, assertSame/assertNotSame.

Hypothetically, you could imagine
long ERROR_CODE = -1;
assertNotEquals(ERROR_CODE, getResponseId());

But I'd rather have someone who recently needed the functionality chime in with their real code.

from junit4.

marcphilipp avatar marcphilipp commented on August 22, 2024

Fixed by #418.

from junit4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.