Category "junit"

Error java.lang.AssertionError: expected: null<null> but was: java.lang.String<null> what does it mean?

I have this strange issue in my Junit 4.12 test code. The application uses Spring Framework 4.1.6 and Hibernate 4. When comparing two beans coming from differen

Mockito when() method not working and getting null pointer exception

I am writing unit test cases using Mockito and JUnit . But getting NullPointerException when running a test. On debugging I get to know that Mockito on method:

No tests found for given includes Error, when running Parameterized Unit test in Android Studio

I have tried to run Parameterized Unit Tests in Android Studio, as shown below: import android.test.suitebuilder.annotation.SmallTest; import junit.framework

Use Mockito 2.0.7 to mock lambda expressions

I want to mock a query provided on my repository like this: @Test public void GetByEmailSuccessful() { // setup mocks Mockito.when(this.personRepo.find

Display errors in JUnit failure trace

I use Selenium Web Driver in Eclipse with JUnit. I need create simple checking if some text exists on the page - if it is, than I need generate error. I want th

ArrayList equality in junit not working although expected and actual are similar

I am using below test method to check whether the Arraylist is sorted as expected. @Test void compareFields() { Assignment14 assignment14 = new Assi

In JUnit 5, how to run code before all tests

The @BeforeAll annotation marks a method to run before all tests in a class. http://junit.org/junit5/docs/current/user-guide/#writing-tests-annotations But is

continue jacoco code coverage report after fail test case

Code coverage report not generated when Test case failed in android studio using Jacoco plugin.How to skip failed test case and generate code coverage report.

JUnit5 - How to get test result in AfterTestExecutionCallback

I write JUnit5 Extension. But I cannot find way how to obtain test result. Extension looks like this: import org.junit.jupiter.api.extension.AfterTestExecutio

JUnit5 - How to get test result in AfterTestExecutionCallback

I write JUnit5 Extension. But I cannot find way how to obtain test result. Extension looks like this: import org.junit.jupiter.api.extension.AfterTestExecutio

Assert to check string contains only numeric values

I want to write a JUNIT test case for checking that a String contains only numeric values. Can anybody suggest me to do so. I am new to junit test case and i cu

Junit (4.12) is not executing after spring-boot 2.6.2 migration

I have migrated from Spring to Spring-boot version 2.6.2. mvn clean install is successful but none of the junit(version 4.12) is executing. After few research I

Using junit @Rule, expectCause() and hamcrest matchers

I have a test: @Rule public ExpectedException thrown = ExpectedException.none(); ... @Test public void testMethod() { final String error = "error message";

How do we do Spark Dataframe testing using JUnit?

We are trying to build an integration test suite using JUnit. Our pipeline (built in Spark using Scala) gives us DataFrames as output, we plan to compare them a

How to assert an actual value against 2 or more expected values?

I'm testing a method to see if it returns the correct string. This string is made up of a lot of lines whose order might change, thus usually giving 2 possible

Spring JUnit: How to Mock autowired component in autowired component

I've got a Spring component I'd like to test and this component has an autowired attribute which I need to change for the purpose of unit testing. The problem i

JUnit5: How to assert several properties of an object with a single assert call?

I want to assert several properties of an object with a single assert call. With JUnit 4 and Hamcrest I would have written something like this: assertThat(pro

Is it at all possible to execute 'mvn test' when tests are in src/main/java and not in src/test/java [duplicate]

I have inherited a project which has over 100 Junit test classes. The problem is the unit test sources and main source files are in the same

Getting "Skipping JaCoCo execution due to missing execution data file" upon executing JaCoCo

I'm using Maven 3.0.3, JUnit 4.8.1, and Jacoco 0.6.3.201306030806, and I am trying to create test coverage reports. I have a project with unit tests only, but

How to use OR condition with TestNG assertions

Is there a way to do assertions with OR with TestNG? This is what I am trying to find: assertEquals(expected, value1 || value2); // Can be any number of valu