Category "junit"

Junit Parameterized Constructor - Wrong Number of Arguments

I am trying to build a parameterized Junit Test in order to test each occurrence of a LinkedHashMap within an ArrayList of LinkedHashMaps. This is because each

JUnit testing got initializationError with java.lang.Exception: No tests found matching

When running JUnit testing , it gave an initializationError: No tests found matching. Like this: prodapi-main-junit initializationError(org.junit.runner.manip

How to write Unit Test for below Exception Handler method using mockito?

@ExceptionHandler({ ConstraintViolationException.class }) public ResponseEntity<Object> handleConstraintViolation(ConstraintViolationException ex, WebRequ

Mockito argument matcher and hibernate lazyinitialization

I've created the following captor: public class CompanyOwnerMatcher extends ArgumentMatcher<CompanyOwner> { private String uuid; CompanyOwnerMa

How to properly remove a dependency in a Maven project

I have a Java Maven project where I have some dependencies defined in the pom.xml file. Recently I decided to move from Junit to TestNG so I deleted the Junit d

Android Studio cannot resolve org.junit

I am using JUnit tests in Android Studio 1.2.2. The tests run without a problem. The only thing that puzzles me is that Android Studio cannot resolve the actual

Spock TestEngine with ID 'spock' failed to discover tests

When I was running unit test with spcok,An exception appears: Internal Error occurred. org.junit.platform.commons.JUnitException: TestEngine with ID 'spo

Why does Android Studio say "Test events were not received"?

I'm trying to unit test in my android application, and this is the simple test tutorial what i'm doing. import static org.junit.Assert.*; import org.junit.Test

How to use MockRestServiceServer with multiple URLs?

I need to configure multiple expectations on an instance of MockRestServiceServer. The expectations are for two different URLs: Call URL #1 Call URL #1 (for a

How to link @BeforeEach method with specific @Test methods (Java, JUnit)?

For example we have 2 classes: BaseTest and Test. Test extends BaseTest. BaseTest.class contains 2 methods with @BeforeEach annotations. @BeforeEach void setU

How to mock Base64 in Android?

I am writing a Unit test for a class that uses android.util.Base64 and I get this error: java.lang.RuntimeException: Method encode in android.util.Base64 not m

Test a method that use a spring service

I have a problem testing a method in Java (I use jUnit 4) and this method to test make a call to a repository and should throw an exception if something is wron

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.