Comments (9)
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.
Agreed. Use assertThat instead of assertEquals and the "older" asserts supplied by JUnit directly.
from junit4.
Looks resolved.
from junit4.
Re-requested in http://twitter.com/#!/KevlinHenney/status/96329124712415232
from junit4.
I added assertNotEquals to Object, long and double. For which branch should I send my pull request?
from junit4.
Marcus,
It would be against 4.10. Truth be told, I'm still not 100% sold on the functionality...
from junit4.
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.
@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.
Fixed by #418.
from junit4.
Related Issues (20)
- Confusing problem... get differernt result between `main method` and `test method` HOT 7
- Compilation error in org.junit.runner.Result - ObjectInputStream.GetField.get(name, object) throws ClassNotFoundException
- Update to hamcrest 2.2 HOT 16
- Test case grouping - Run subset of test cases depending on specific environment variables HOT 8
- Thread context classloader not reset between tests HOT 1
- Cross site scripting HOT 1
- How to test Redis Time out exception for @Cacheable method with Junit+ Spring integration test HOT 3
- Make Assert failNotEquals public HOT 1
- Assert error messages are not clear HOT 2
- Exception handling of suite() method breaks Jenkins JUnit test history reporting HOT 6
- Add support for "dynamic" default runner selection via system property HOT 8
- When will a new version of junit be released? HOT 1
- JUnitCore could not invoke test HOT 1
- Strange links on "Download and Install" page HOT 1
- junit-4.13.2 compilation error with java 21 HOT 4
- Treat org.opentest4j.TestAbortedException the same as AssumptionViolatedException HOT 4
- Which junit version supports Java 17 ? HOT 2
- Assert check not consistent HOT 9
- Receiving excessively long build DEBUG logs after updating maven-surefire-plugin from 2.22.2 to 3.3.0 HOT 1
- Refactoring Confirmation for Replace ‘expected’ Attribute with Try-Catch HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from junit4.