Questions tagged [assertj]

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

386 questions
2
votes
1 answer

JUnit test JTable cell tooltips

I am building a JTable with a custom TableCellRenderer that sets a tooltip to some cells. The tooltip gives further information about the cell's content, so it is a different one for each cell that has it. For testing, I am using AssertJ and JUnit.…
Bowi
  • 1,378
  • 19
  • 33
2
votes
2 answers

Maven + AssertJ + IntelliJ = confusion with scope?

I want to add a test framework to my current maven project in IntelliJ. I choose AsserJ, because the style looked best to me. I tried their tutorial, but it fails to provide enough help.…
Tigerware
  • 3,196
  • 2
  • 23
  • 39
2
votes
2 answers

Testng assertj report and continue

I'm using AssertJ to test web using fluentlenium and extent reports for reporting the results. I asked before the question but forgot to mention the use of AssertJ. The provided answer was to extend soft assert and that it has onAssertFailure…
A.H
  • 23
  • 5
2
votes
1 answer

JInternalFrameFixture.comboBox() in AssertJ Swing 3.2

I'm migrating some code from FEST Swing 1.2.1 to AssertJ Swing 3.2. In the old code there are calls to JInternalFrameFixture.comboBox() JInternalFrameFixture.label() JInternalFrameFixture.slider() Unfortunately I do not see any matching method in…
palacsint
  • 28,416
  • 10
  • 82
  • 109
2
votes
2 answers

Maven test compile does not find class in classpath

I've got a little project with this pom...
Florian Schaetz
  • 10,454
  • 5
  • 32
  • 58
2
votes
1 answer

Generics and ClassCastException: why do I get this exception, how do I "work around" it?

For one of my projects, I am attempting to get rid of string-based unit testing; one class I have as a target right now is ParsingResult. I have successfully converted another class with a custom AssertJ assertion, so I am now trying to write a…
fge
  • 119,121
  • 33
  • 254
  • 329
1
vote
1 answer

Idiomatic way to force AssertJ to compare by identity?

AssertJ's assertThat(...).isEqualTo() method compares using .equals() by default. This is often the right choice, but sometimes you really do want to compare by exact object identity / referential identity instead ("double equals" == in Java,…
sh-at-cs
  • 64
  • 7
1
vote
2 answers

Is it a good idea to use ID for comparison with AssertJ?

I got the following class with which I want to test my repository: package de.gabriel.vertretungsplan.repositories; import de.gabriel.vertretungsplan.models.Fach; import de.gabriel.vertretungsplan.models.Klasse; import…
Gabriel
  • 233
  • 1
  • 3
  • 11
1
vote
1 answer

import static org.assertj.core.api.Assertions.assertThat not suggested by IntelliJ

Newbie, big project, copy/paste unit testing task. Using IntelliJ Ultimate, when trying to import assertThat(), I get to choose only between: import static com.mysema.commons.lang.Assert.assertThat; or import static…
NaPal.
  • 11
  • 1
1
vote
2 answers

AssertJ exception handling (feat.assertThat+isInstanceOf)

I have been on this problem for hours but couldn't get close to solution. Any help will be appreciated. public static int enterTheAmount(){ int final LOTTO_PRICE = 1000; int amount = Integer.parseInt(Console.readLine()); …
Dan Lee
  • 13
  • 2
1
vote
2 answers

Test that at least one element of a list contains a specific element using assertj

Suppose i have players which form a team which participates at a tournament. I want to test, that the tournament has at least one team with name T1 with a player named Paul. package org.example; import java.util.List; public class Tournament { …
peer
  • 257
  • 2
  • 11
1
vote
2 answers

Idiomatic way of comparing results of two completableFutures with assertj

There are 2 completable futures cf1 and cf2 defined as follows: CompletableFuture cf1 = CompletableFuture.completedFuture(true); CompletableFuture cf2 = CompletableFuture.completedFuture(true); Technically, one could do: var…
Bhushan
  • 590
  • 1
  • 7
  • 23
1
vote
0 answers

How to ignore node with sub nodes in JsonAssertions?

I am using net.javacrumbs.jsonunit.assertj, JsonAssertions, assertThatJson to compare two jsons. I need to ignore node with array and sub-nodes. So in this example I would like to ignore all in node "ignoreAllIn" { "md": { "i":…
Simon
  • 11
  • 2
1
vote
2 answers

assertThat returns() BigDecimal usingComparatorForType

I like to use asserThat().returns() combination to test the content of my objects. Unfortunately it does not work out of the box with BigDecimal because the equals method requires identical scale, which is not always the case. Instead the…
1
vote
1 answer

Unit test after upgrading the Spring Boot version hasOnlyOneElementSatisfying() method is not working

Unit test was working fine in its previous version while after updating the version it shows error public class PersonSearchUtil { private final HashSet result = new HashSet<>(); . . . public…
Jimmy
  • 995
  • 9
  • 18