4,151 questions
1
vote
1
answer
85
views
How to control test class execution order in JUnit 5 suites?
I'm organizing my tests using JUnit 5's @Suite and @SelectClasses, but need to control the execution sequence of the test classes. According to the documentation, @SelectClasses doesn't guarantee ...
2
votes
1
answer
62
views
Why @Transactional method does not behave as expected in tests?
I'm testing that:
@RunWith(SpringRunner.class)
@DataJpaTest
@Import({ OrderService.class, UserService.class })
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
public class ...
0
votes
1
answer
54
views
Can't verify that in anonymous inner class method throw exception
Given:
Java 8
Mockito 4.3
Junit 4.11
Here my java code:
public interface ClientListener {
void addClientStatusListener(StatusListener statusListener);
}
@FunctionalInterface
public interface ...
0
votes
1
answer
109
views
java.lang.NoSuchMethodError: org.mockito.invocation.InvocationFactory.createInvocation(Ljava/lang/Object
Java 8
Maven 3.9.
I want to verify is void private method call.
I try PowerMock.
pom.xml
<properties>
<powermock.version>2.0.2</powermock.version>
</properties>
...
0
votes
1
answer
109
views
kotlin.test.BeforeTest is not resolved
After updating Android libraries (including Kotlin) I found that @BeforeTest became unresolved (@Before is resolved, it belongs to org.junit).
import org.junit.Before
import org.junit.Test
import org....
0
votes
0
answers
51
views
ClassFormatError while writing a JUnit 4 test with MockitoJunitRunner
I am trying to write a JUnit test for my Android project. I am using the Android junit:4.13.2 and Mockito org.mockito:mockito-core:5.15.2 dependencies.
Here is the gradle sourceSet which I have used
...
-1
votes
1
answer
450
views
Cucumber and gherkin feature test with error No matching tests found in any candidate test task
gradle failed to find my test. already switching between JUnit too and its still not fix it, and it still give same error as its not found. i tried everything to find a way to look for solution but no ...
0
votes
1
answer
526
views
Maven Surefire Plugin Configuration with JUnit5 and TestNG Failing
I currently migrated a project from JUnit4 to JUnit5. The test classes are a mixture of JUnit and TestNG. My current maven plugin is written in the parent POM like:
<!-- https://mvnrepository.com/...
0
votes
2
answers
350
views
SpringBoot 2.7.18 with H2 DB
I Have an SpringBoot 2.7.18 with H2 2.3.232, with this SQL for testing:
CREATE TABLE IF NOT EXISTS EXERCICE
(
EXERCICE_ID NUMBER AUTO_INCREMENT,
TYPE_SITE_ID NUMBER,
...
0
votes
0
answers
57
views
Why am I getting NoClassDefFoundError even after having the class in testing in Android Studio
I'm trying to test my Helper class which is a Kotlin class in Android Studio. I've JUnit dependencies as it is that I get with new Project creation. But, whenever I try to run test, I get ...
1
vote
0
answers
87
views
Can't write a good test for service layer in java application
I've tried to make some tests for Service layer in my java project. The test supposed to simply mock adding a new patient to database. After constantly failing, I simply gave up, and came here for ...
1
vote
1
answer
146
views
ApplicationContext not loading in Junit 4 test case after upgrading to spring-boot v3.2.10
This used to work in spring-boot v2 but after upgrading to spring-boot v3 test case gives error. The @Value annotation is not picking the right value from application.properties file because the ...
0
votes
0
answers
28
views
Mocking Cache Config class failing
I haven't mocked the configuration class for cache config properties. Can someone help me with possible unit tests for this cacheable layer ?
CacheConfig.java
import com.github.benmanes.caffeine.cache....
0
votes
0
answers
52
views
Osgi framework bundle junit execution issue .junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests
I am upgrading my application with latest equinox osgi version and getting below error while executing test cases. What I understood from multiple sources that this is related to org.junit.jupiter.api ...
0
votes
1
answer
122
views
How to write a tests for PickVisualMediaRequest, in android studio?
I have a fragment in my app that requests the user to upload an image. How can I write a Junit test that runs on the emulated device that would select and image from the pop up? I am also wondering if ...