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 : NoSuchMethodException on softAssert

I have been experimenting with assertJ as an alternative to the current assertion library,hamcrest, thats used in my teams project. Thus far I have the following class: Animal.java package com.assertions.demo.assertj; public class Animal { private…
jbailie1991
  • 1,305
  • 2
  • 21
  • 42
0
votes
1 answer

AssertJ Swagger test is stuck on executing

I'm trying to adopt Swagger in REST API development (Spring Boot web application). API documenting process and code generation based on swagger spec works good, and now I've faced a problem writing integration tests using assertj-swagger and…
naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
0
votes
1 answer

Assertj Comparing extracted which are String arrays

In my case I need to request the set of names from two different systems and verify they are equal (regardless order). Most probably I don't understand smth, but this code works fine: assertThat(asList(assertThat(firstJSON) …
boringMax
  • 1
  • 2
0
votes
1 answer

How does AssertJ's `usingComparatorForFields` work?

Related to How to compare recursively ignoring given fields using assertJ? As a work around the problem, I tried to rig the comparator for the field which I don't want the comparator to compare and made it return…
Tarun Maganti
  • 3,076
  • 2
  • 35
  • 64
0
votes
1 answer

Java Testing Deep not equals

I am struggling to find a way to test two object for deep non-equality (field by field) using jUnit or/and AssertJ. Is there any way? Something like this. not(assertThat(mSubjectManager.getSubjectById(subjectId)) …
Lukáš Řádek
  • 1,273
  • 1
  • 11
  • 23
0
votes
2 answers

How to use `any` matcher with parameters to the object

I am facing a problem with using assertThat(object.method(new SomeClass(someParam))) as a result, the comparison is when actually running the test, the matcher is comparing object references not the contents of the object as equals method isn't…
Tarun Maganti
  • 3,076
  • 2
  • 35
  • 64
0
votes
0 answers

JUNIT AssertThatThrownBy Capture Return Value

I try to test exception thrown by a method like this: Assertions.assertThatThrownBy( () -> myMethod(paramA, paramB)) .isInstanceOf(IllegalArgumentException.class).hasMessage(error); However the problem is I still need to make more assertions…
Ace
  • 1,501
  • 4
  • 30
  • 49
0
votes
0 answers

Launching an application (JProfiler specifically) by its executable using assertj-swing

I need to automate JProfiler GUI (switching between various tabs, extracting textual data and verifying them). I have been trying to use assertj-swing library. However, JProfiler is launched by an executable and not by class file. Is there a method…
0
votes
1 answer

AssertJ result feedback with "iterable asserts"

I'm checking that a list of Strings contains a specific number meeting a certain condition, specifically that they contain a substring, ignoring case. So I came up with this (reasons for the failedResults field will become apparent): class…
mike rodent
  • 14,126
  • 11
  • 103
  • 157
0
votes
1 answer

AssertJ asserting that List contains only long[]

Is there a way to assert that a List contains only/exactly long[] array? Code: // arrange long[] result = {1, 2, 3, 4, 5}; // act List digitPowNumbers = SumDigPower.findDigitPowNumbers(1, 6); // assert …
doublemc
  • 3,021
  • 5
  • 34
  • 61
0
votes
1 answer

AssertJ is throwing test failure

I am trying to do a exception testcase in junit using AsssertJ. But I am getting the following error : Results : Failed tests: BatchManagerTests.testUniqueBatchpart:225 Expecting code to raise a throwable. Tests run: 149, Failures: 1, Errors: 0,…
sromit
  • 900
  • 3
  • 16
  • 43
0
votes
0 answers

Testing asynchronous API, with Given-When-Then style, multiple When-Then?

I know it is recommended to have "single assert" in tests or single group of "When" and "Then" in BDD paradigm. I was thinking whether it would be okay to relax this assumption, when testing an asynchronous API. Where request has to be first made,…
KarolDepka
  • 8,318
  • 10
  • 45
  • 58
0
votes
1 answer

make assertj print special characters?

assertThat( "abd\n123" ).isEqualTo( "abd\r\n123" ); prints this ] PasswordCredentialsSerializationTest.testSerialize:33 expected:<"abd[ 123"> but was:<"abd[] 123"> asside from interesting positioning of square brackets, is there any way to get…
xenoterracide
  • 16,274
  • 24
  • 118
  • 243
0
votes
2 answers

Soft assertions in base class for multiple tests

I am new to testing and I have to use assertj framework for softassertions. These are standard assertions that are repeated over multiple tests. For every test I define new SoftAssertion, do the asserts and then do .assertAll() This seems like a lot…
LameDuck31
  • 21
  • 3
0
votes
1 answer

Does AssertJ provide an assertion method on iterables that has a Consumer as argument?

AssertJ provides the method hasValueSatisfying(Consumer requirement) for Java Optional objects. This method allows to create assertions on the optional value like this: assertThat(myOptional).hasValueSatisfying(v -> { …
Joern
  • 1,926
  • 1
  • 13
  • 18
1 2 3
25
26