How to mock LocalDateTime.now() in java 8

Please, I am testing a functionality ABC that uses LocalDateTime.now(). In the methode ABC i’am comparing an entry date with the LocalDateTime.now() I want my test to be passed at any day so i have to …

How to ignore a method call inside a method that is being tested?

I am trying to make a test pass with mockmvc and it is failing with the following error message: Caused by: org.apache.kafka.common.config.ConfigException We have Kafka in our service layer as a …

Best practice for Unit Testing class which is mostly responsible to call methods of dependencies, but contains logic as well

Let’s assume I have StartCommandHandler which has responsibility to create some file with required files. But for doing this I have to give him a set of sub-responsibilities, like: Checks whether …

Can I add seconds to current date without using Calendar Library in Java?

I want to get the current time in Java, and now I want to add 15 seconds above the time. Can I do this with a library other than the Calendar library in java? import java.util.Calendar; public …

Dynamically add property sources to SpringBootTest

Similar to Springboot unit test set @Configuration Properties dynamically but the context is different. In my case I have a TestContainer running a custom MySQL database that is prepopulated with a …

Create Post Api in Java for Test Rail

Im trying to create a java post request to create a test run on test rail, however it doesn’t seem to be working heres my code: public class create_run { public JSONObject AddTestRunTest() throws …

Android Espresso: How to create test-suite which may launch separate test classes with different activities?

I have just started studying Espresso tests, but I have searched throw StackOverFlow topics and couldn’t found solution for my needs. Prehistory of my question: I have android application with lots …

TestNG. can’t run a single test method

I have Selenium+Eclipse+Java Project+Eclipse TestNG plugin. For example, my code is: public class TestClass { @Test public void test1() throws Exception { … } //@Test public void test2() …

TestNG: More than one @DataProvider for one @Test

I’m using TestNG for Eclipse. Is it possible to give two data providers step by step to the same test-function? I could put both providers in one, but that is not what I want. I need (not like in this …

How to Re-run failed JUnit tests immediately?

Is there a way to have an JUnit Rule or something similar that gives every failing test a second chance, just by trying to run it once again. Background: I have a large Set of Selenium2-WebDriver …