1. Explore
  2. »
  3. JUnit

JUnit errors

A unit testing framework for Java

http://junit.org
Solution coverage:
Summary coverage:

Top patterns

  1. JUnit test assertion failed

    AssertionError is thrown when using JUnit's internal assertions methods compare two different values and those are not equal. Also, the developer can invoke the method when the test logic fails.

    The simplest code to reproduce the error is the following:

    import static org.junit.Assert.fail;
    
    public class FailTest { 
    
       @Test 
       public void shouldAssertFail() { 
          ...
          if( ... ) {
             fail("Any message");
          }
       } 
    }
    

    Mind the static import. The fail is part of the JUnit API.

    Your best course of action is to use the debugger to see why the test is failing and what is the condition that is not being met.

  2. Assert.failNotEquals() has thrown an AssertionError
    No solution
  3. Assert.assertTrue() has thrown an AssertionError

    Check your pattern declaration or check your assert declaration.

Error patternsPackagesClassesMethodsExceptions
DescriptionException TypeEntry MethodWeb pages

JUnit test assertion failed

java.lang.AssertionError
org.junit.Assert.fail
4191Web pages
1Solution
AssertionErrorAssert.fail()4191

Assert.failNotEquals() has thrown an AssertionError

java.lang.AssertionError
1 frames hidden
org.junit.Assert.failNotEquals
1925Web pages
AssertionErrorAssert.failNotEquals()1925

Assert.assertTrue() has thrown an AssertionError

java.lang.AssertionError
1 frames hidden
org.junit.Assert.assertTrue
1858Web pages
1Solution
AssertionErrorAssert.assertTrue()1858

Assert.assertEquals() has thrown an AssertionError

java.lang.AssertionError
2 frames hidden
org.junit.Assert.assertEquals
1746Web pages
AssertionErrorAssert.assertEquals()1746

Assert.assertEquals() has thrown an AssertionError

java.lang.AssertionError
3 frames hidden
org.junit.Assert.assertEquals
1508Web pages
AssertionErrorAssert.assertEquals()1508

JUnit "equals" comparison failed

org.junit.ComparisonFailure
org.junit.Assert.assertEquals
658Web pages
1Solution
ComparisonFailureAssert.assertEquals()658

JUnit assertTrue failed

java.lang.AssertionError
2 frames hidden
org.junit.Assert.assertTrue
652Web pages
1Solution
AssertionErrorAssert.assertTrue()652

Assert.assertEquals() has thrown an AssertionError

java.lang.AssertionError
4 frames hidden
org.junit.Assert.assertEquals
542Web pages
AssertionErrorAssert.assertEquals()542

Assert.failNotEquals() has thrown an AssertionFailedError

junit.framework.AssertionFailedError
1 frames hidden
junit.framework.Assert.failNotEquals
315Web pages
AssertionFailedErrorAssert.failNotEquals()315

Assert.assertTrue() has thrown an AssertionFailedError

junit.framework.AssertionFailedError
1 frames hidden
junit.framework.Assert.assertTrue
314Web pages
AssertionFailedErrorAssert.assertTrue()314

Assert.assertEquals() has thrown an AssertionFailedError

junit.framework.AssertionFailedError
2 frames hidden
junit.framework.Assert.assertEquals
307Web pages
AssertionFailedErrorAssert.assertEquals()307

Assert.assertEquals() has thrown an AssertionFailedError

junit.framework.AssertionFailedError
3 frames hidden
junit.framework.Assert.assertEquals
280Web pages
AssertionFailedErrorAssert.assertEquals()280

Assert.assertThat() has thrown an AssertionError

java.lang.AssertionError
1 frames hidden
org.junit.Assert.assertThat
237Web pages
AssertionErrorAssert.assertThat()237

Assert.assertNotNull() has thrown an AssertionError

java.lang.AssertionError
2 frames hidden
org.junit.Assert.assertNotNull
203Web pages
AssertionErrorAssert.assertNotNull()203

Assert.assertThat() has thrown an AssertionError

java.lang.AssertionError
2 frames hidden
org.junit.Assert.assertThat
180Web pages
AssertionErrorAssert.assertThat()180

Assert.assertFalse() has thrown an AssertionError

java.lang.AssertionError
2 frames hidden
org.junit.Assert.assertFalse
176Web pages
AssertionErrorAssert.assertFalse()176

Assert.assertEquals() has thrown a ComparisonFailure

junit.framework.ComparisonFailure
1 frames hidden
junit.framework.Assert.assertEquals
167Web pages
ComparisonFailureAssert.assertEquals()167

Assert.assertEquals() has thrown an AssertionFailedError

junit.framework.AssertionFailedError
4 frames hidden
junit.framework.Assert.assertEquals
153Web pages
AssertionFailedErrorAssert.assertEquals()153

Assert.assertNotNull() has thrown an AssertionError

java.lang.AssertionError
3 frames hidden
org.junit.Assert.assertNotNull
145Web pages
AssertionErrorAssert.assertNotNull()145

Assert.assertFalse() has thrown an AssertionError

java.lang.AssertionError
3 frames hidden
org.junit.Assert.assertFalse
117Web pages
AssertionErrorAssert.assertFalse()117

Assert.assertTrue() has thrown an AssertionFailedError

junit.framework.AssertionFailedError
2 frames hidden
junit.framework.Assert.assertTrue
104Web pages
AssertionFailedErrorAssert.assertTrue()104

Suite.runChild() has thrown a RuntimeException

java.lang.RuntimeException
1 frames hidden
org.junit.runners.Suite.runChild
84Web pages
RuntimeExceptionSuite.runChild()84

Assert.assertNull() has thrown an AssertionError

java.lang.AssertionError
2 frames hidden
org.junit.Assert.assertNull
73Web pages
AssertionErrorAssert.assertNull()73

Unexpected exception was thrown

java.lang.Exception
org.junit.internal.runners.statements.ExpectException.evaluate
73Web pages
1Solution
ExceptionExpectException.evaluate()73

Assert.assertNotNull() has thrown an AssertionFailedError

junit.framework.AssertionFailedError
2 frames hidden
junit.framework.Assert.assertNotNull
68Web pages
AssertionFailedErrorAssert.assertNotNull()68

ParentRunner.validate() has thrown an Exception

java.lang.Exception
2 frames hidden
org.junit.runners.ParentRunner.validate
67Web pages
ExceptionParentRunner.validate()67

ParentRunner.<init>() has thrown an Exception

java.lang.Exception
3 frames hidden
org.junit.runners.ParentRunner.<init>
64Web pages
ExceptionParentRunner.<init>()64

Unexpected exception was thrown

java.lang.AssertionError
org.junit.internal.runners.statements.ExpectException.evaluate
62Web pages
1Solution
AssertionErrorExpectException.evaluate()62

BlockJUnit4ClassRunner.<init>() has thrown an Exception

java.lang.Exception
4 frames hidden
org.junit.runners.BlockJUnit4ClassRunner.<init>
60Web pages
ExceptionBlockJUnit4ClassRunner.<init>()60

No tests method found running test via proxy

java.lang.Exception
org.junit.internal.requests.FilterRequest.getRunner
57Web pages
ExceptionFilterRequest.getRunner()57

Assert.assertNotNull() has thrown an AssertionFailedError

junit.framework.AssertionFailedError
3 frames hidden
junit.framework.Assert.assertNotNull
53Web pages
AssertionFailedErrorAssert.assertNotNull()53

FailOnTimeout$StatementThread.run() has thrown an AssertionError

java.lang.AssertionError
13 frames hidden
org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run
52Web pages
AssertionErrorFailOnTimeout$StatementThread.run()52

JUnit and Hamcrest with "assertThat" comparison failed

java.lang.AssertionError
org.junit.Assert.assertThat
50Web pages
1Solution
AssertionErrorAssert.assertThat()50

TestCase.assertEquals() has thrown a ComparisonFailure

junit.framework.ComparisonFailure
2 frames hidden
junit.framework.TestCase.assertEquals
48Web pages
ComparisonFailureTestCase.assertEquals()48

TestCase.assertEquals() has thrown an AssertionFailedError

junit.framework.AssertionFailedError
5 frames hidden
junit.framework.TestCase.assertEquals
48Web pages
AssertionFailedErrorTestCase.assertEquals()48

Assert.assertThat() has thrown an AssertionError

java.lang.AssertionError
1 frames hidden
org.junit.Assert.assertThat
43Web pages
AssertionErrorAssert.assertThat()43

Assert.assertNull() has thrown an AssertionError

java.lang.AssertionError
3 frames hidden
org.junit.Assert.assertNull
42Web pages
AssertionErrorAssert.assertNull()42

TestResult$1.protect() has thrown an AssertionFailedError

junit.framework.AssertionFailedError
3 frames hidden
junit.framework.TestResult$1.protect
41Web pages
AssertionFailedErrorTestResult$1.protect()41

AllDefaultPossibilitiesBuilder.runnerForClass() has thrown an Exception

java.lang.Exception
7 frames hidden
org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass
41Web pages
ExceptionAllDefaultPossibilitiesBuilder.runnerForClass()41

TestResult.runProtected() has thrown an AssertionFailedError

junit.framework.AssertionFailedError
4 frames hidden
junit.framework.TestResult.runProtected
40Web pages
AssertionFailedErrorTestResult.runProtected()40

Assert.fail() has thrown an AssertionError

java.lang.AssertionError
1 frames hidden
org.junit.Assert.fail
40Web pages
AssertionErrorAssert.fail()40

TestCase.run() has thrown an AssertionFailedError

junit.framework.AssertionFailedError
6 frames hidden
junit.framework.TestCase.run
39Web pages
AssertionFailedErrorTestCase.run()39

TestSuite.run() has thrown an AssertionFailedError

junit.framework.AssertionFailedError
8 frames hidden
junit.framework.TestSuite.run
37Web pages
AssertionFailedErrorTestSuite.run()37

FrameworkMethod$1.runReflectiveCall() has thrown a DeploymentException

org.jboss.arquillian.container.spi.client.container.DeploymentException
42 frames hidden
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall
34Web pages
DeploymentExceptionFrameworkMethod$1.runReflectiveCall()34

FrameworkMethod$1.runReflectiveCall() has thrown a DeploymentException

org.jboss.arquillian.container.spi.client.container.DeploymentException
42 frames hidden
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall
33Web pages
DeploymentExceptionFrameworkMethod$1.runReflectiveCall()33

RunnerBuilder.safeRunnerForClass() has thrown an Exception

java.lang.Exception
8 frames hidden
org.junit.runners.model.RunnerBuilder.safeRunnerForClass
32Web pages
ExceptionRunnerBuilder.safeRunnerForClass()32

TestCase.assertEquals() has thrown an AssertionFailedError

junit.framework.AssertionFailedError
4 frames hidden
junit.framework.TestCase.assertEquals
31Web pages
AssertionFailedErrorTestCase.assertEquals()31

ParentRunner$2.evaluate() has thrown a BeanCreationException

org.springframework.beans.factory.NoSuchBeanDefinitionException
23 frames hidden
org.junit.runners.ParentRunner$2.evaluate
31Web pages
BeanCreationExceptionParentRunner$2.evaluate()31

ClassRequest.getRunner() has thrown an Exception

java.lang.Exception
9 frames hidden
org.junit.internal.requests.ClassRequest.getRunner
27Web pages
ExceptionClassRequest.getRunner()27

Test class should have exactly one public zero-argument constructor

java.lang.Exception
1 frames hidden
org.junit.runners.BlockJUnit4ClassRunner.validateConstructor
27Web pages
1Solution
ExceptionBlockJUnit4ClassRunner.validateConstructor()27
Nothing to list here.
Nothing to list here.
Nothing to list here.
Nothing to list here.