All Questions
46
questions
1
vote
1
answer
102
views
How to check using ArchUnit if there is any use of reflection in the source code?
I want to write a JUnit Test Case using ArchUnit to check if there is usage of reflection in the source that is written by the developer and fail the test case if so. How can I achieve this using ...
0
votes
0
answers
25
views
Kotlin tests with coveragge in intelij failed assertions
I have problem with intelij and coverage tests, when im running unit tests, without coverage, just by normally intelij run tests, all tests are success, but when i try to run it by tests with coverage,...
0
votes
1
answer
110
views
Spring boot Junit tests fail : I/O error on GET request for "http://localhost:8080/v1/pr": Failed to connect to localhost/[0:0:0:0:0:0:0:1]:8080
I am writing Junits for my spring boot code. I am unable to mock and test RestTemplate.
I went with SpringBootTest as an integration test approach instead of simple unit test, as the resttemplate was ...
2
votes
1
answer
250
views
How avoid loading unused beans in springBootTest?
I have a test class like this there I want to test only controller layer:
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class MyControllerTest {
@Autowired
...
-1
votes
1
answer
405
views
Kotlin Junit error: class kotlin.Unit cannot be cast to class java.lang.Boolean
Setup: Springboot with Kotlin
Description: try to mock a java method, from a kotlin Junit test file
Error source code line:
Mockito.`when`(workflowService.sendEvent(ArgumentMatchers.anyString(), ...
0
votes
1
answer
117
views
Is there a way to check on SpringBoot if the xml file has a common query condition?
<select id="findById" resultType="foo">
SELECT *
FROM foo_table
WHERE id = #{id}
limit 1
</select>
<select id="findByStauts" resultType="...
0
votes
1
answer
275
views
Cannot update entity on mongodb spring boot unit test having unique constraint
I have the following model (kotlin):
@ApiModel(description = "Showtime model specifying the scheduled movie display")
@Document
class Showtime(
@ApiModelProperty(notes="Date of ...
0
votes
2
answers
812
views
How to write a test for the Application class in Spring Boot for Kotlin
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
@SpringBootApplication
class GetThingsDoneApplication
fun main(args: Array<...
0
votes
1
answer
201
views
Kotlin - @AliasFor not overriding attribute from @DisplayName
I'm trying to create an annotation for tests with a few meta-annotations. I'd like to pass a name parameter and use it for @DisplayName's value, by using @AliasFor. The code looks like this:
@Target(...
-1
votes
1
answer
638
views
Is it possible to verify the same method with different parameters 2 times in kotlin?
The method will be called two times with different parameters:
method("test1")
method("test2")
In my test I am trying to check if the parameters are right or not
`when`(
...
0
votes
1
answer
247
views
Kotlin - Spring - How to pass an interface with generics as an argument to Mockito.any()
In Kotlin I'm using Mockito to perform unit tests in the when method I'm trying to test my repository which extends JpaRepository which also extends QueryByExempleExecutor and from this interface I ...
1
vote
1
answer
834
views
How to avoid initializationError in kotest with SpringBootTest?
I have a simple JUnit "smoke" test which check if Spring context is loaded correctly:
@SpringBootTest
class ContextLoadJUnit {
@Test
fun contextLoads() {
//empty by design
...
0
votes
1
answer
1k
views
how to mock a method call inside another method in same class
I am trying to test a method methodB (as shown in the code below). I want to return directly from methodA without going into the actual code of methodA.
I have used when/thenReturn and doReturn/when ...
-1
votes
1
answer
194
views
How to check assert which returns the list of boolean?
This one is ok , it is working.
assert(Class.method()[0].example.name == "example"
But how can I check all of names, not only one.
assert(Class.method().map {it.example.name == "example&...
0
votes
1
answer
1k
views
@Autowired not working inside testcontainers
I am using test containers to make integration tests with the MSSQLServer image and when I am trying to inject my repository I am recieving the following error:
lateinit property modelRepository has ...