aspose file tools*
The moose likes Testing and the fly likes Junit error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Junit error" Watch "Junit error" New topic
Author

Junit error

Jayasri Alaparthi
Ranch Hand

Joined: Aug 14, 2006
Posts: 67
Hi friends,
I am running java class extending testcase in Eclipse IDE 3.2 adding junit4.1.jar in external libraries, I got failure as 1 with the following warning junit.framework.AssertionFailedError: No tests found , please help me.
Thanks,
Bhargavi
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2510
    
  10

You will have to post your test class code to allow us to give good info.

Most often this error occursd when you're mixing JUnit 3 and JUnit 4 functionality.
Like:
  • Your test class inherits from TestCase (junit 3 style)
  • and your test methods are annotated with @Test.
  • Show your code, and we'll be able to help you better.

    Regards, Jan


    OCUP UML fundamental and ITIL foundation
    youtube channel
    Jayasri Alaparthi
    Ranch Hand

    Joined: Aug 14, 2006
    Posts: 67
    Hai Jan,
    Thanks for giving response, here is my code and I used junit4 test in Eclipse3.2 and import external lib of junit-4.1 jar file and wrote the code as such

    package com;

    import junit.framework.TestCase;


    public class aaaa extends TestCase {
    public aaaa(String name){
    super(name);
    }



    public void sayTest(){

    int answer = 2;
    assertEquals((1+1), answer);
    }
    }
    I got the error junit.framework.AssertionFailedError: No tests found in com.aaaa
    at junit.framework.Assert.fail(Assert.java:47)
    at junit.framework.TestSuite$1.runTest(TestSuite.java:93)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:120)
    at junit.framework.TestSuite.runTest(TestSuite.java:228)
    at junit.framework.TestSuite.run(TestSuite.java:223)
    at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Ernest Friedman-Hill
    author and iconoclast
    Marshal

    Joined: Jul 08, 2003
    Posts: 24187
        
      34

    In "classic" JUnit, tests are methods named as testXXX(). In JUnit 4, tests are methods marked with the @Test annotation. You've done neither of those things here.


    [Jess in Action][AskingGoodQuestions]
    Jan Cumps
    Bartender

    Joined: Dec 20, 2006
    Posts: 2510
        
      10

    sayTest() should be testSay().

    Regards, Jan
    Jean-Claude Rouvinez
    Ranch Hand

    Joined: Aug 26, 2003
    Posts: 35
    Jan Cumps wrote:sayTest() should be testSay().


    According to JUnit.org there is still a problem with JUnit 4.5
    and no answer has been posted under on JUnit.org

    Who knows the official forum concerning JUnit4.5? There is not much activity under JUnit.org.

    Best Regards


    Jean-Claude
    Ernest Friedman-Hill
    author and iconoclast
    Marshal

    Joined: Jul 08, 2003
    Posts: 24187
        
      34

    Jean-Claude Rouvinez wrote:
    Jan Cumps wrote:sayTest() should be testSay().


    According to JUnit.org there is still a problem with JUnit 4.5
    and no answer has been posted under on JUnit.org


    If you extend TestCase, use method names like testXXX(), and include the @Test annotations, then your tests work under JUnit 3, JUnit 4, and under some mysterious future version of JUnit in which extending TestCase doesn't pick up textXXX() methods, so I don't understand what that poster on that other site is on about. If he doesn't name his tests as testXxx(), then they don't work under JUnit 3, which is one of his goals.

    In any event, this is unrelated to what the poster did here, because this poster did not use annotations nor did he use textXXX() names.

    Also, PleaseDontWakeTheZombies.
    Ravissant Saraswat
    Greenhorn

    Joined: Mar 15, 2010
    Posts: 20
    Hi Everyone ,
    I had been looking for exactly the same kind of post and am so glad I found it. I'm facing a similar error while trying to run my junit testcase from a main class.
    Now, what I basically have to do is run a couple of junit test cases, one after the other to benchmark the performance of a service for different loads. When I run my main class, I get the following error :

    warning(junit.framework.TestSuite$1)junit.framework.AssertionFailedError: No tests found in AllTests
    at EvaluationBenchmarkingMain.main(EvaluationBenchmarkingMain.java:24)



    The following is my main class :



    The following is the AllTests class :




    And the following is the JUnit test class (Just one for now) , that I intend running from a separate project through the above main class:



    I also tried changing the name of the method to "testTC0008_PDSTest()" but that didnt help either.

    Please, Please help!!

    Thanks in advance,
    Ravissant
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Junit error