Category "junit"

Test Fails with "when() requires an argument which has to be 'a method call on a mock' " error on maven project(no frameworks used)

Hi I am trying to mock an insertion in my database and run it for a test. The test is failing with and error "when() requires an argument which has to be 'a met

Test Fails with "when() requires an argument which has to be 'a method call on a mock' " error on maven project(no frameworks used)

Hi I am trying to mock an insertion in my database and run it for a test. The test is failing with and error "when() requires an argument which has to be 'a met

How to test Kafka OnFailure callback with Junit?

I have the following code to send data to Kafka: @Service public class KafkaSender{ @Autowired private KafkaTemplate<String, Employee> kafkaTempla

Error: Static mocking is already registered in the current thread

Junit test case getting failed: existing static mocking registration must be deregistered Test class: @RunWith(MockitoJUnitRunner.class) public class DeleteRe

How to generate html test report for junit in sbt?

I have junit tests in my scala sbt project. I know, that I can generate html reports for ScalaTest with: testOptions in Test += Tests.Argument(TestFrameworks.

How to generate html test report for junit in sbt?

I have junit tests in my scala sbt project. I know, that I can generate html reports for ScalaTest with: testOptions in Test += Tests.Argument(TestFrameworks.

Could not find Spring Profile when uses JUnit Runner in IDEA

I'm trying to run a JUnit Test in IntelliJ IDEA, but the Runner could not find the Spring Profile. this message is displayed in the log: --spring.profiles.acti

Kafka consumer unit test with Avro Schema registry failing

I'm writing a consumer which listens to a Kafka topic and consumes message whenever message is available. I've tested the logic/code by running Kafka locally an

What will be the output of this code by unit testing with mockito and Junit

public ResponseEntity<Object> getAirlines() { LOGGER.info("getAirlines: Getting all airlines."); return new ResponseEntity<>(this.airlineSer

Spring AOP with Mock, Spy. AspectJProxyFactory cannot addAspect Mock instance

I am trying unit tests where an aspect class works well while unit testing. Situtation. upgrade Spring Boot from 1.5.9 -> 2.3.1. Mockito, Junit frameworks ar

Spring AOP with Mock, Spy. AspectJProxyFactory cannot addAspect Mock instance

I am trying unit tests where an aspect class works well while unit testing. Situtation. upgrade Spring Boot from 1.5.9 -> 2.3.1. Mockito, Junit frameworks ar

Jasypt not decrypting properties during junit testing, but works fine when spring boot app runs

I have a Spring Boot application with a few properties encrypted with Jasypt, and I provide the secret key with the following VM option: -Djasypt.encryptor.pass

Difference between @Mock, @MockBean and Mockito.mock()

When creating tests and mocking dependencies, what is the difference between these three approaches? @MockBean: @MockBean MyService myservice; @Mock: @Mock

JUnit GUI doesn't show executed test methods

I run a test class, the outprint in console is correct, but the list of the @Test methods doesn't appear in the JUnit tab: How to fix it? Does the asterisk o

Mock ResultSet with Mockito

How to mock the resultset? In the test class trying to mock the resultset as below but, when trying to test getting error as UnnecessaryStubbingException at s

Spring Boot Kotlin Mockito @MockBean dependency throws IllegalStateException null on method call

I am relatively new to Spring and Kotlin. I ran into this problem and it does not seem that there is a comprehensible (for me) explanation anywhere on the Inter

Maven not running JUnit 5 tests

I'm trying to get a simple junit test running with maven but it is not detecting any tests. Where am I going wrong? The project directory Project -> src ->

Spring Email with Greenmail: Authentication Credentials Invalid

I am trying to write test code for Spring Email using Greenmail. This works perfectly with 1.5.5 version of Greenmail, however when I try to update the version

How to redirect JUnit testing to the console in Eclipse?

I am a blind screen reader user and have a problem with JUnit in Eclipse. The results of tests passing or failing is represented as far as I understand visuall

Why isn't @DisplayName working for me in JUnit 5?

For some reason, I'm really having a hard time getting display names to actually be respected in JUnit 5 with Kotlin. Here's a test file I created for the purp