Skip to content

Tag: junit4

NullPointerException on validating email

I am writing a unit test to check the email validation logic. The logic is throwing null pointer exception when you run the test. But it works fine with emulator. Can someone help me solving this? Below is my unit test. The error I am getting is, Answer android.util.Patterns.EMAIL_ADDRESS.matcher(email).match…

junit test for stateless ejb + jpa

I would like to write a junit test for my stateless ejb + jpa demo code. I think it is actually not a junit test, it is an integration test. I have a stateless ejb with an injected EntityManager and PostgreSQL database server is used. I use CDI (Spring is not used in my project) and EclipseLink with a persist…

maven error: package org.junit does not exist

I’m trying to create the javadoc with maven and it fails. It also fails when doing the verify. I get the following error: In my pom.xml file I have the following lines: and my local repository contains the junit jar file: The code is fine because in my laptop, which I have no access now, I van run: with…

Loop through array, each element a JUnit test

I have a JUnit 4 test that loops through an array of test data: Because it’s all in one test method, the whole test stops as soon as one element in the array fails. Is there a way around that, without making a method for each test item? Maybe something with reflection? Answer Use JUnit 4’s paramet…