Questions tagged [junit]
Popular unit testing framework for Java and Scala. The latest version, JUnit 5, supports rich annotation-based and parameterized tests. Consider using in conjunction with the Java or Scala tag to indicate your use case.
junit
28,069
questions
0
votes
0
answers
9
views
JUnit 5 - Migration - Custom test annotation no longer detected?
I had the following custom test annotation that worked in JUnit4 that IntelliJ and JUnit no longer wants to recognize:
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE })
@Retention(RUNTIME)
...
0
votes
0
answers
15
views
pytest failing to generate xml correctly
Unable to generate junit xml file correctly, after a failure generation of the file stops and no further tests are executed. The command works without the junit argument. I have also tried adding '-...
0
votes
1
answer
31
views
SimpleAgedCache: Why can't I get my SimpleAgedCache to pass its tests?
I'm new to coding and programming, and I found an interesting SimpleAgedCache exercise on GitHub that uses JavaScript. I feel like I've done the correct coding, and the exercise should pass its tests. ...
-1
votes
2
answers
50
views
How to write a unit test with a controller method that has protected code in it [duplicate]
I am trying to write a unit test for the following controller:
@RestController
@RequestMapping(value = ENDPOINT_URL)
public class MainController extends RestControllerBase {
MainService ...
-1
votes
0
answers
33
views
How to mock a method call which is private and static? [closed]
TestThisMethod is the class and command Store is the method invoked from useCommandStore. I want to mock commandStore which is private and static, when and then of JUnit is not working here.
Class ...
-3
votes
0
answers
32
views
In Springboot, Junits [closed]
In Spingboot, I am writing Junits for services and I am getting error as "The method findByLine1(String) is undefined for the type ExampleService". Why am I getting this? How to slove this ...
-1
votes
0
answers
500
views
Test cases failing and getting NoClassDefFound Could not initialize class XXX after upgrading Maven to 3.9.6 version
Test class
`@BeforeEach
public void initResource() {
serviceLocator = mock(ServiceLocator.class);
service = mock(Service.class);
resource = new MappedDefaults(serviceLocator, service);
...
0
votes
1
answer
59
views
Asserting availability of SubTypes of T
I would like to assert whether every element of an array is a sub type of a particular class. So I wrote a helper like this:
private <T> void assertContainsAllSubtypes(
List<? ...
1
vote
2
answers
43
views
Is it advisable to repeat an integration test that is used in more than one method?
I'm developing a project. This project has a repository (UserRepository) which is referenced by other parts of the project, I want to know if I have to test the repository method each time it is ...
1
vote
1
answer
21
views
Java unit test failing due to null KeyHolder
I'm creating new unit tests for an application and I'm stuck because the KeyHolder is not returning a valid object.
For context, here are my classes:
ScriptDao class:
@Repository
public class ...
0
votes
0
answers
10
views
The user is experiencing an error in their Junit program, despite using assert-equals with two integer numbers
I have used the Assert Equals (Expected, Actual) method which takes two integers value and stores its sum in the Actual variable. I am putting my code below.
public class CalcTest
{
@Test
...
0
votes
0
answers
16
views
Junit error Can't load log handler "1catalina.org.apache.juli.AsyncFileHandler"
Getting below error while running junit.
Can't load log handler "1catalina.org.apache.juli.AsyncFileHandler"
java.lang.ClassNotFoundException: 1catalina.org.apache.juli.AsyncFileHandler
java....
-1
votes
0
answers
20
views
java.lang.RuntimeException: Could not setup GlassFish Embedded Bootstrap
I have a deployment class for integration tests in my project that is inheriterd by every test class. This class is annotated by:
@ArquillianSuiteDeployment
@RunWith(CustomArqullianRunner.class)
I'm ...
0
votes
0
answers
23
views
In Java, using Mockito fails to initialize MockMaker plugin
When I try to run this code:
package __6__240703.test.user_repository;
import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.*;
import __6__240703.main.user_repository....
0
votes
1
answer
43
views
junit 5 runs specific cucumber feature twice
Running Cucumber with JUnit 5 works ok as long as all feature files are run.
@Suite
@IncludeEngines("cucumber")
@ConfigurationParameter(key = Constants.FEATURES_PROPERTY_NAME, value = "...