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,078
questions
0
votes
1
answer
24
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
32
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
49
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
63
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
504
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
65
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
23
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
11
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
30
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
22
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
32
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
46
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 = "...
0
votes
0
answers
26
views
mockito, mock new file or mock file.exists() [duplicate]
Prerequisite: Powermockito cannot be used and the original code cannot be changed.
how to let
File file = new File("xxxx");
file.exists() returns true.
public void testFile(String path) {
...
0
votes
0
answers
23
views
How to pass a Junit Test for a Primefaces FileUploadEvent
i have a doubt about how to pass a JUnit test for a Primefaces FileUploadEvent.
The methods is this:
public void cambiarLogoCrear(FileUploadEvent event) {
cambiarLogo(event, false);
}
private ...