I’m trying to write a test case where my scenario is that two byte arrays should be not equal.
Can I do this with junit?
Or do I have to use something external like Hamcrest? I couldn’t change the code in this answer to do the job
Please give a sample.
I prefer doing this the Hamcrest way, which is more expressive:
Or the short version with static imports:
(The
IsEqualmatcher is smart enough to understand arrays, fortunately.)Note that a limited version of Hamcrest is part of the JUnit 4.x distribution, so you don’t need to add an external library.