Questions tagged [assertj]

AssertJ provides a set of strongly-typed assertions to use for unit testing (either with JUnit or TestNG).

386 questions
0
votes
2 answers

Should not working as expected

I am new to Should testing. Always used Assert but I'm trying new options. This simple test is not working and I am curious to understand why. Profile.js class Profile { constructor(profile_name,user_name,email,language) { …
Ed de Almeida
  • 3,675
  • 4
  • 25
  • 57
0
votes
1 answer

AssertJ JUnitSoftAssertions and Guava assertions

I'm addicted to the AssertJ JUnit rule JUnitSoftAssertions. It is really conveniente, you just add it as a test class field @Rule public JUnitSoftAssertions softy = new JUnitSoftAssertions(); and you chain several assertThat on it. Now, I added the…
JeanValjean
  • 17,172
  • 23
  • 113
  • 157
0
votes
2 answers

Delaying a thrown exception to add a soft assertion instead

Consider I have a method to test, which may have side-effects (like files created on the file system), and may throw an exception. Some of the side effects can be observed (and tested) even when the exception is thrown. My sample test code is…
Bass
  • 4,977
  • 2
  • 36
  • 82
0
votes
2 answers

Assertions for non-deterministic behavior

Does AssertJ (or JUnit) have a way to chain, in a single (fluent) expression, several assertions on the same unit under test where one of the assertions may throw an exception. Essentially, I'm trying to assert that: If a unit under test (X)…
Simeon Leyzerzon
  • 18,658
  • 9
  • 54
  • 82
0
votes
3 answers

AssertJ multidimensional arrays assertion (deep equals)

Is there any option in AssertJ to make deep assertion of 2-d (N-d) arrays? Pretty much the same as java.util.Arrays#deepEquals() does but with assertion exception and prettified fail message like "element arr1[i][j] expected to be X, but was Y" Here…
radistao
  • 14,889
  • 11
  • 66
  • 92
0
votes
1 answer

AssertJ and Groovy force type?

I'm learning Groovy as I develop this project so I'm not sure of my ground. I have an assertion like so: assertThat( spyCH.getLoopCount() ).isEqualTo( 1 ) There is no explicit method getLoopCount(), but there is an instance variable loopCount in…
mike rodent
  • 14,126
  • 11
  • 103
  • 157
0
votes
1 answer

Hamcrest or assertj : test element in list with requirements

using hamcrest and java 8, what's the easiest way (one liner) to assert that a collection contains a element with a specific set of requirements? I'd like to be able to retrieve the element, if it exists, and perform some tests on it, in one go (and…
gateQ
  • 13
  • 4
0
votes
2 answers

AssertJ to log assertion's results

I'm trying to understand if is possible to configure AssertJ to log the negative result of an assertion to a file without interrupting the routing that is running the comparison. The reason behind this request is that we are comparing the JSON…
Kerruba
  • 1,779
  • 1
  • 17
  • 25
0
votes
2 answers

What is the best way to check all JSON properties values type?

I'm trying to check in my integration test if all of values from some specific property has the same type. I was trying to do it along with jsonPath and JsonPathResultMatchers but without success. Finally in I did something like this : MvcResult…
Artur Skrzydło
  • 1,135
  • 18
  • 37
0
votes
2 answers

Check lists of objects for equality without order check in their List property

Preconditions: I am deserializing a complex JSON into data class. The destination class has a bit of a complex hierarchy. I have a list of objects List. Where ServiceFeature is the following (it's in kotlin, but does not matter): data class…
Mike
  • 725
  • 1
  • 8
  • 11
0
votes
2 answers

How do I Assert against an Array and failing only if there is no match after all the values were verified

I am working on a test using NightwatchJs framework. I need to compare the actual value against a set of valid values. However my current implementation throws multiple failures while the correct value is found in the expected result array. I want…
Alextgda
  • 43
  • 4
0
votes
1 answer

Integrating AssertJ and ExtentReport

Here's an example method explaining what I'd like to do. public void myMethod(Method m){ report = new ExtentReports("filename"); test = report.startTest("testName"); String actual = "sssssss"; String expected = "xxxxxxxx"; …
0
votes
1 answer

AssertThat error: Cannot access path (java.nio.file.Path not found)

I want to use Robolectric for Unit Testing but I am trying a simple test with robolectric and I am stuck at the beginning. I followed the manual, I did the same with the examples and even other posts couldn't help me. Every time I get the error…
mischi
  • 25
  • 9
0
votes
1 answer

Test automation approach for application with multiple RCP plugins with Swing components embedded

I would like to do functional test automation of a huge application consisting of more than 20 Eclipse RCP plugins. The most challenging part is almost all RCP plugins embed some legacy Swing components. Now I am almost certain that there is no…
0
votes
2 answers

How to group exception messages from AssertJ for better reporting?

At first, we used TestNG Asserts for all our automation test validations which can throw a predefined error message. The allure report, groups the failures based on the error messages making it very easy to read and understand. Recently we started…
Vel Ganesh
  • 537
  • 3
  • 12
  • 32