Questions tagged [junit4]

Version 4 of the popular Junit Java Unit testing framework

Version 4 of the popular JUnit Java Unit testing framework.

New features are the introducing of annotations to use the framework.

Use this tag only for question related to features provided by version 4. Use for general questions.

4127 questions
1
vote
0 answers

AndroidJUnit4 not startable from IntelliJ

I have put a AndroidJUnit4 test into the 'app\src\androidTest\java\myPackage' Folder and wanted to start the test from IntelliJ. Obviuosly there is something wrong, because I am missing the green start Icon on the left. My…
mcfly soft
  • 11,289
  • 26
  • 98
  • 202
1
vote
1 answer

assumeTrue in JUnit4 is erring instead of ignoring tests

I'm using JUnit 4 (junit-4.8.2.jar) to run tests on my Java project and am running into problems when using assumeTrue. I have this basic set up: public class ClientTest extends TestCase { @BeforeClass public void setUp() { …
Casey Crites
  • 471
  • 1
  • 4
  • 15
1
vote
1 answer

Mockito can't mock a property of a third class when I'm testing another one

I'm having trouble with Mockito because I can't mock a property of a third class when I'm testing another one. The class I'm testing: @Component public class MyTransformer { @Autowired private MyService myService; public Output…
Ex.
  • 57
  • 7
1
vote
2 answers

Unresolved Reference: mockwebserver

I'm writing a test suite with mockwebserver. I entered all of the dependencies from the official github page. Every time I try to run the test I receive Unresolved reference: mockwebserver There's no option to import. The lettering isn't red on…
petestmart
  • 500
  • 11
  • 27
1
vote
1 answer

NoClassDefFoundError: org.junit.rules.TestName in Spock 2.0:

I'm trying to update my test project from Spock 1.3 to 2.0: testImplementation group: 'org.spockframework', name: 'spock-core', version: '2.0-groovy-2.5' But getting the following error at the test start: ':compileTestGroovy'. Caused by:…
Bohdan Nesteruk
  • 794
  • 17
  • 42
1
vote
0 answers

How Do I Verify the Correct Number of Responses When Testing With MockServer?

I'm in the process of creating some unit tests for a java service that needs to make HTTP requests to an external web service. I decided to use MockServer (https://www.mock-server.com/#what-is-mockserver) to mock out the external HTTP calls but so…
pbuchheit
  • 1,371
  • 1
  • 20
  • 47
1
vote
2 answers

Junit4 execution order in inheritance

I am using JUnit4. I am trying to run tests in specific order. In individual classes the method order is as expected because of the @FixedMethodOrder annotation. But when using inheritance the order is not enforced. I want my TestClassA to be…
JingJong
  • 207
  • 1
  • 3
  • 14
1
vote
1 answer

Using liquibase and H2 database for unit tests in SpringBoot

I am trying to use my liquibase scripts to set up tables in H2 database for my unit tests in springboot. Below are the liquibase scripts for one of my tables
Akash Sharma
  • 330
  • 3
  • 18
1
vote
2 answers

JmsListenerContainerFacotory Not available: NoSuchBeanDefinitionException, even though have configured a DefaultJmsListenerContainerFactory

I am writing unit/integration test to check whether the JMS listener using IBM MQ is getting called correctly. There are two listeners in my IncomingDataListener. They are for two types of data comming in the same queue, processed by…
1
vote
1 answer

org.springframework.dao.DataIntegrityViolationException While running Junit testcase in sprintboot

Have developed a springboot project and Using H2 database in writing testcases, if we run individual controllerTest class , All testcases are passing. but we run all the test classes together few test classes are failing with below…
Amulya M
  • 149
  • 1
  • 12
1
vote
0 answers

Mockito change the arguments passed to a mock

i have a class which reads and writes values from/to a byte-buffer. My write method looks like this: public void write(final ByteBuffer buffer) { buffer.putInt(messageLength); buffer.putShort(version); foo.write(buffer); …
maku
  • 11
  • 2
1
vote
2 answers

Junit5 testSuite with SelectClasses not working in android unit test

i am trying to create a test suite for Unit test of android application, but it always fails with different kinds of configuration error, one among that is as follows, FAILURE: Build failed with an exception. * What went wrong: Execution failed for…
Reprator
  • 2,859
  • 2
  • 32
  • 55
1
vote
1 answer

Mockito cannot resolve a public static method of a class

I have a Component class called AppUtil with a bunch of public static methods: @Component public class AppUtil { // Methods, fields... public static List getActiveProfiles() { return…
Jason
  • 2,495
  • 4
  • 26
  • 37
1
vote
2 answers

@Test annotation not working junit 4

I'am trying to test a class with Jnuit 4 in a maven project. The test runs successfully when I run it from my STS, but when I try to run it from maven command line, I get the following error: annotations are not supported in -source 1.3 (use -source…
tintin
  • 5,676
  • 15
  • 68
  • 97
1
vote
2 answers

Can't get rid of the JUnit Vintage Engine

I'm currently migrating my JUnit tests from version 4 to version 5. I have followed these steps: https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ So basically, none of my classes import JUnit4 libraries anymore, like…
Zoette
  • 1,241
  • 2
  • 18
  • 49