Question

I would like to know how would be the implementation to compare 2 equal results (int).

I looked for FEST documentation, but I just could find a few tutorials.

When implementing with assertThat, I cannot find the right implementation to compare same values.

Was it helpful?

Solution 2

I also not found any equals method which compare two int parameters. But I think there aren't designed Fest API to compare primitives. So, you can use simple JUnit API for compare primitives. Meanwhile I found this example:

FEST Android:

assertThat(view).isGone();

Regular JUnit:

assertEquals(View.GONE, view.getVisibility());

Please check this documentation. The ANDROID class containt many asserThan methods to compare android objects.

OTHER TIPS

FEST-Android doesn't have an api to compare primitives, but regular FEST does. You can refer to it by its fully qualified name if you want to use it.

This would look like:

org.fest.assertions.api.Assertions.assertThat(myObject.getInt()).isEqualTo(5);

Not necessarily ideal. It's too bad these aren't included in FEST-Android, as I end up either doing this or mixing and matching with JUnit assertions, which I don't love.

You can find the code here.

EDIT: You can actually just import both methods, you don't need to use the fully qualified name.

import static org.fest.assertions.api.Assertions.assertThat;
import static org.fest.assertions.api.ANDROID.assertThat;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top