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

AssertJ/JUnit Failure Trace

When program fails to find a component in a test case, a failure trace is shown. It shows attributes of components in the hierarchy. For example: [name=null, text='Close', enabled=true, visible=true, showing=false] I wonder what value of visible…
Huy Ha
  • 120
  • 10
0
votes
1 answer

Can not find symbol when using assertThatThrownBy with a lambda which has unchecked assignment

I'm using JUnit and AssertJ to test my code, and here is the test: public class FooTest { @Test public void test(){ Foo f = new Foo(); assertThatThrownBy(() ->…
ZumiKua
  • 506
  • 4
  • 10
0
votes
2 answers

I can not test the Swing GUI with AssertJ

I can not test the GUI in my application using the AssertJ library. So as not to spread all the code of your program, wrote a test program to show the essence of the problem. package AssertJ; import javax.swing.*; import java.awt.*; import…
OnlyTarg
  • 190
  • 10
0
votes
3 answers

org.hamcrest.Matcher's method equalTo() returning value like this <>

I am working on spring 5.0.7 project where I have some testcases which are getting fails which was working fine with previous version of spring. when I am executing following statement assertEquals("My message",401, equalTo(401)); getting…
Tej Kiran
  • 2,218
  • 5
  • 21
  • 42
0
votes
2 answers

Java assertj double containsSequence

How do I specify the double/float tolerance to assertj while comparing a double sequence? Here, items is a List and ScoredItem has 2 attributes itemId and score. assertThat(items).extracting("score").containsSequence(3.0, 2.0, 1.0, 0.35,…
Nik
  • 5,515
  • 14
  • 49
  • 75
0
votes
0 answers

Mockito 2.19.0 - Null returned upon static method being used in class method under test, not testable with Mockito?

I'm fairly new to Mockito having gone through their official documentation and a couple of online tutorials in regards to writing tests, as such there is probably something I am missing when I am getting a null returned from a static method I am…
iranicus
  • 73
  • 1
  • 1
  • 5
0
votes
1 answer

Use isEqualByComparingTo in Predicate

normal use of nice assertj-matchers like isEqualByComparingTo: BigDecimal number = ... assertThat(number).isEqualByComparingTo(BigDecimal.valueOf(...)); however I have a list of BigDecimals and want to check each element in the list for equality by…
hotzen
  • 2,800
  • 1
  • 28
  • 42
0
votes
3 answers

I don't want assertJ assertThat ends test when assertion fails

I use assertJ and have multiple assertThat assertions in my test case. When first assertion fails test is finished but I don't want that. I'd like to have information about all failing assertions after single executing of test case. Is it any way to…
kris82pl
  • 977
  • 3
  • 12
  • 21
0
votes
1 answer

How to select JCheckBox by text in AssertJ Swing when there are multiple checkboxes in the JPanel

The application has checkboxes text depending on the the selection of ComboBox in previous Step. I need to select one of the checkboxes in the JPanel using text. Is there a way to do it in AssertJ Swing
Sangam
  • 1
  • 1
0
votes
1 answer

Choose one of three identical swing components using AssertJ

I use AssertJ to test my swing application. When I try to use this code frame.button(JButtonMatcher.withText("text").andShowing()).click();` I get this error: Found more than one component using matcher…
Vadym
  • 163
  • 1
  • 4
  • 19
0
votes
1 answer

Why FieldByFieldComparator from assertJ doesn't work?

I tried to use FieldByFieldComparator from AssertJ when comparing two lists of JavaBeans elements with BigDecimals fields and it doesn't work. When I compare these two BigDecimals (eg. 1.00 and 1.000000), using default BigDecimal comparator,…
0
votes
2 answers

in JUnit test (java) How to check in a array of array with Assertj librairy?

I want use assertj for cheking a data in array contain a other array. accounts: [class AccountResource { resourceId: 010001781LV bicFi: null accountId: null name: Livret A Rosalie details: LIVRET A …
Stéphane GRILLON
  • 11,140
  • 10
  • 85
  • 154
0
votes
1 answer

AssertJ to Hamcrest equivalency (only for Spring MVC Test): How test each POJO item of a collection (with dates)

For a Spring Framework App, about Testing: The business layer is working with AssertJ and JUnit. The web layer is working with JUnit and Spring MVC Test, where the latter works mandatorily with Hamcrest. See Is there a way to use AssertJ…
Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
0
votes
1 answer

AssertJ - The method isEqualToComparingFieldByFieldRecursively don't work with RuntimeException object

Summary The method isEqualToComparingFieldByFieldRecursively don't work with RuntimeException object. The check always return true even if we change the RuntimeException message in the expected RuntimeException. Not working example (always…
agauchy
  • 117
  • 3
  • 10
0
votes
1 answer

swing application opens and closes down immediately when invoked with assertJ command (TestNG + assertJ Swing)

Trying assertJ-swing for UI testing of java-swing based application. Situation: Sample application in JavaApp.java (with Main class) works fine when it is invoked from this java file (running it as Java application). But when it is invoked from…
Atul K
  • 1
  • 2