I’m trying to initialize (by mocking) two objects with the annotation @MockBean It seems only to work if i call the method mock(className), but since i want to use the mocked class on multiple methods i don’t want to keep repeating the same code in my test methods. This is my test class: I don’t want to use the Spring
Tag: testing
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 file exists in the FTP If Not downloads files from multiple sources to the temp folder Then executes some script in the folder Then read generated file after script
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 …
What does this ObjectWeb error mean: “Unsupported class file major version 56” and how do I fix it?
(Editors note: This is objectweb, not the JVM complaining. Be very sure before knee-jerk closing as duplicate) I’m sort of reviving a project that was left in a broken state when I try to run the tests I get this error: What does that mean? Any ideas how to fix it? The Maven project includes: but commenting out that plug
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 lot of data (not using the SQL batch loading approach because the data is an anonymized copy of production and doing it through SQLs makes the boot up time
How to assert that some String contains at least one value from the List ?
I’m testing some UI functionality with Java and AssertJ. So when I receive some massive string from UI, I should verify if that String contains at least one predefined value from List<String>. It is easy to do opposite thing – verify if list contains at least once some String value but this is not my case. I can’t find solution
Mocking Unirest with mockito
I am in my starting programming phase and I wanted to ask about mocking Objects with Mockito, more specifically is the Unirest response. Let’s say I have a database, and I dont what to bother it every time I do testing, and I want to use Mockito for that, but the problem is I am not sure how to create
I cannot @Spy Object in Cucumber Spring Boot Test in two Steps Definitions
I’m having a problem running cucumber test with Spring Boot 2. I have two steps definitions and in both clases I try to spy an object with mockito trying to capture the argument passed to one method of this class. The point is that since Cucumber only allows one Spring Application Context Configuration I’ve created an abstract class to configure
Karate karate-config.js not a js function
I’m trying use karate for e2e tests and have started with a minimal setup. I want to create some config items in karate-config.js for use in the tests but karate is reporting that file is not a js function and hence the test fails trying to get the config: This is my karate-config.js: This is my insurer.feature test: This is
What is mockito-inline and how does it work to mock final methods?
Javadocs in Mockito says – “Starting with version 2.7.6, we offer the ‘mockito-inline’ artifact that enables inline mock making without configuring the MockMaker extension file”. What does this mean? How does mockito-inline works ? Why a separate artifact for mockito-inline? Answer I stumbled upon this too and the answer is buried quite deep in the docs, so here it is.