Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Junit error

 
Jayasri Alaparthi
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
     
    Jayasri Alaparthi
    Ranch Hand
    Posts: 67
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Pie
    Posts: 24211
    35
    Chrome Eclipse IDE Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    Jan Cumps
    Bartender
    Posts: 2588
    11
    C++ Linux Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    sayTest() should be testSay().

    Regards, Jan
     
    Jean-Claude Rouvinez
    Ranch Hand
    Posts: 35
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
     
    Ernest Friedman-Hill
    author and iconoclast
    Marshal
    Pie
    Posts: 24211
    35
    Chrome Eclipse IDE Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 20
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic