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
1 answer

Which assertion library for Java has the best integration with Allure Reports?

I'm using Allure Reports to provide test results on my automated tests. However, I'm noticing that assertions are not showing up as step in the reports. I would like to know which assertions library has best integration with Allure, so that when I…
Dax Ortiz
  • 1
  • 3
0
votes
1 answer

Is it possible to assert there are only duplicates with an AbstractIterableAssert?

I have something like this: assertThat(someList).extracting("someField") and I want to continue the assert with asserting that only duplicates exist in the extraction. Is there a good way to do this?
Hans Wurst
  • 376
  • 1
  • 3
  • 12
0
votes
0 answers

Assertj-Generator maven plugin custom variable

I was wondering if there is a way to add a custom variable when using the assertj-assertions-generator-maven-plugin. I would like to introduce a variable in the maven pom that would be the entry point class name. What I have found in multi-module…
John B
  • 32,493
  • 6
  • 77
  • 98
0
votes
1 answer

Test that either one property contains value in AssertJ

Having following code: @Data @AllArgsConstructor public class TolkienCharacter{ String nick; String name; String surname; } @Test void go(){ TolkienCharacter frodo = new TolkienCharacter("GoodFrodo", "Frodo", "Baggins"); …
Artur
  • 661
  • 1
  • 6
  • 23
0
votes
0 answers

Builder pattern in unit testing vs mocking all collaborators

Lets say a university offers courses and courses are attended by students: class University{ List courses; } class Course{ Category category; List students; } class Student{ Gender getGender(); boolean…
peer
  • 257
  • 2
  • 11
0
votes
2 answers

Ignoring a field in Map that is a member of a class while testing

I have an Object called ReconciliationResult public class ReconciliationResult { Map recordValue; List keyValues; Origin origin; ReconciliationResultStatus status; public enum ReconciliationResultStatus { …
Beez
  • 478
  • 9
  • 23
0
votes
1 answer

How to verify the data type of Json response field in rest assured

How can we verify the Json data type of mentioned fields such as "price", "ck", "name", "enabled" and "tags" in rest assured test. { "odd": { "price": 200, "ck": 12.2, "name": "test this", "enabled": true, …
0
votes
1 answer

ArchUnit: Prevent assertJ statements without assertion

Is it possible to create an ArchUnit rule which prevents AssertJ statements without an assertion? For exampel: This AssertJ statement is perfectly ok, because it has both a assertThat part and an…
Olaf
  • 3,786
  • 4
  • 25
  • 38
0
votes
1 answer

Asserting Java enum values and fields with AssertJ

Given a simple enum like this: @AllArgsConstructor @Getter public enum PaymentMethod { CREDITCARD(1), PAYPAL(2), APPLE_PAY(3), GOOGLE_PAY(4); private final long id; } How can I write a JUnit test with AssertJ assertions which…
Robert Strauch
  • 12,055
  • 24
  • 120
  • 192
0
votes
0 answers

AssertJ's SoftAssertions.assertSoftly is hanging my test at 892 assertions

Im doing a database comparison test using serenity-bdd. I am currently testing 892 records. All 892 failed as expected. AssertJ's SoftAssertions.assertSoftly appears to have ran through all 892 successfully. But then it hangs the test and wont…
Tim Boland
  • 1,872
  • 4
  • 23
  • 37
0
votes
1 answer

AsserJ - chaing together returns and extracting

Sometimes sonar cloud is complaining about number of assertions in tests. I wanted and found out how I can chain assertions one to another, but theres a case where I cannot figure out how I can chain assertions. import java.util.List; import…
siwonpawel
  • 55
  • 1
  • 6
0
votes
1 answer

Search JPanel by name

I was following the How to use CardLayout Java Swing tutorial and I got to the point where the panel is added to the layout: JPanel cards; final static String BUTTONPANEL = "Card with JButtons"; //Create the "cards". JPanel card1 = new…
ClaudiaR
  • 3,108
  • 2
  • 13
  • 27
0
votes
2 answers

How to assert on a map value object member?

Given are a map like this: Map myMap = new HashMap<>(); and a class BestClass like this: class BestClass{ int a; int b; } Now, this map is being populated during the program process. Is there a clean way, not including…
dushkin
  • 1,939
  • 3
  • 37
  • 82
0
votes
1 answer

kotest equivalent to usingElementComparatorIgnoringFields from assertJ

assertJ allows you to check for element-wise list equality while ignoring user specified fields like so assertThat(listOfObjects) .usingElementComparatorIgnoringFields("field1", "field2", ...) .containsExactly(object1, object2, ...) I have…
mooglin
  • 500
  • 5
  • 17
0
votes
1 answer

AssertJ: issue with Assertions.assertThat().usingRecursiveComparison().ignoringFields()

I'm using assertj-core:3.21.0 and JDK 17 Here is an simple example that fails. This works in JDK 16 and assertj-core:3.19.0. @AllArgsConstructor @Data class Test { @JsonIgnore private final…
user3908406
  • 1,416
  • 1
  • 18
  • 32