Pattern selector

Most relevant patterns first. Most helpful ones displayed. Click here to show all.

  1. Assert.assertTrue() has thrown an AssertionFailedError
    JUnit
    40
    101
    36
  2. JUnit fail method
    JUnit
    94
    257
    97

Your stack trace compared to the selected pattern

Jump to solutionsExpand frames
junit.framework.AssertionFailedError: output dir exists?
    at junit.framework.Assert.fail(Assert.java:47)
    at junit.framework.Assert.assertTrue(Assert.java:20)
    at org.apache.mahout.clustering.kmeans.TestKmeansClustering.testKMeansMRJob(TestKmeansClustering.java:412)

Solution

JaviRpo2 months ago

AssertionFailedError 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 shouldAssertStrings() { 
      ...
      if( ... ) {
         fail("Any message");
      }
   } 
}

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

External results for this pattern (10)

  1. Mesbah-Alamvia GitHub1 day ago
    cos(double)[0] :: expected:<-0.9999876894265599> but was:<-0.99998768942656>
    Show stack trace
  2. rdeltourvia GitHub4 days ago
    Outputted json isn't as expected. Values do not match(/messages[6]/message) Expected: "Error while parsing file 'The version is required in the XML declaration.'." Actual: "Error while parsing file 'XML宣言にはバージョンが必要です。'." Values do not match(/messages[7]/message) Expected: "Fatal Error while parsing file 'The version is required in the XML declaration.'." Actual: "Fatal Error while parsing file 'XML宣言にはバージョンが必要です。'." expected:<0> but was:<2>
    Show stack trace
  3. wingman-pentahovia GitHub4 days ago
    No message found for this stack trace.
    Show stack trace
  4. lewismcvia GitHub4 days ago
    Validation of file succeeded when it should have failed expected:<false> but was:<true>
    Show stack trace
  5. apupiervia GitHub4 days ago
    expected:<0> but was:<1>
    Show stack trace
  6. johnjohndoevia GitHub1 week ago
    No message found for this stack trace.
    Show stack trace
  7. Dawid Loubservia Google Groups1 week ago
    expected:<1> but was:<0>
    Show stack trace
  8. Dawid Loubservia Google Groups1 week ago
    null
    Show stack trace
  9. El Deffovia Google Groups1 week ago
    null
    Show stack trace
  10. Maxime Gréauvia JIRA1 week ago
    Expected: <null> but was: file:/srv/ciagent/workspace/target/test-classes/repo/MyClass.groovy
    Show stack trace