The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

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.

0
votes
0answers
8 views

Junit: injecting a dependency

I was facing an issue regarding injecting dependencies in a class. Class A had a dependency, B, which is annotated with @Autowired. B class is itself annotated with @Service In unit test for A, ...
1
vote
3answers
24 views

Catching multiple exceptions with Unit Method

I am trying to write a JUnit for my suchAutor() method. The Problem is that I throw two different Exception and I only know how to handle tests that throw one exception. public Buch[] suchAutor(...
2
votes
1answer
18 views

AlertDialog unit testing - java.lang.VerifyError: Bad type on operand stack

I have an activity MyActivity.java in which I am generating an AlertDialog using AlertDialog.Builder(this);. Now I am trying to write a unit test (junit) for MyActivity.java by treating is as a simple ...
0
votes
0answers
26 views

how to pass a json file to an API from a test class to test the API with @Requestpart

am writing testcase for an API with one parameter as @Requestpart, i tried sending files, multipartfile objects to invoke that method but there was no use This is the API @RequestMapping(value = ...
0
votes
0answers
7 views

Do you see the issue on my exampleCourseJson String? I'm getting org.json.JSONException: Unterminated object at character . Details below

@RunWith(SpringRunner.class) @ContextConfiguration(classes={BatchJobConfigDTO.class,BatchJobConfigService.class,BatchJobConfig.class,BatchJobConfigController.class,BatchJobConfigRepository.class}) @...
0
votes
3answers
22 views

Adding a mock object to a Mockito spy List<>

Cant a Mockito Spy List object contains other Mock objects added to it? Any alternatives other than creating actual objects? I have a Spy List Object Class TestableClassTest { @InjectMocks ...
-2
votes
0answers
20 views

How do you write a Junit test ensuring that the output value was previously cleared?

I have a simple line of code that clears the reusable output value in a map-reduce job. How would I write a Junit test ensuring that the code works as expected? outputValue.clear();
0
votes
0answers
8 views

Multidex test instrumentation in Android Library

I have an android library where there's a room database. Adding the unit tests on the DAOs I exceeded the dex limit. Running the instrumentation tests I get FATAL EXCEPTION: main Process: com.a.b....
0
votes
1answer
13 views

Read different values from Excel file every time when test case runs

I have create a excel file with some codes and I am using RepeatRule class to execute my test case 100 times in one class. I need to use different 100 codes every time the test will run rather than ...
0
votes
0answers
17 views

Testing errorChannel in spring integration

I have following configuration <bean id="mail.service.messaging.messageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer" p:autoStartup="true"...
0
votes
0answers
20 views

How to make an executable jar file using IntelliJ from a Selenium/Junit java file?

I am trying to generate a jar file of my test to use it in JMeter, I am trying this solution How to make an executable jar file using IntelliJ from a Selenium/TestNG java file? but the problem in on ...
0
votes
3answers
27 views

PowerMockito mock private methods in springboot

I am trying to mock a private method inside my class under test which is as below. public String processPayment(...) { //some lines privateMethod(...); return ""; } private Object ...
0
votes
1answer
21 views

Testing class by mocking getter

I try to test a class which as two properties with getters where the one getter calls a static method. I want to mock the getter with static method to test the parsing logic of the other getter. The ...
0
votes
1answer
17 views

How can I return multiple answers in sequential calls to a mocked static method

I have a function that returns the value of java.net.InetAddress.getLocalHost().getHostName() I have written a test for my function like so: @PrepareForTest({InetAddress.class, ClassUnderTest.class}...
1
vote
1answer
22 views

WebTestClient check jsonPath against another jsonPath

I have this "content" response which I need to assert some values from it. WebTestClient.BodyContentSpec content = response.expectStatus().isOk() .expectBody() ...

15 30 50 per page