Announcement Announcement Module
Collapse
No announcement yet.
Junit Test class error !! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Junit Test class error !!

    Hi,
    I have written CustomerTest class.

    Code:
    package com.exit41.orderperfect.customeridentification.test.unittest;
    
    import junit.framework.TestCase;
    import junit.framework.*;
    
    import com.exit41.orderperfect.customeridentification.core.Customer;
    
    public class CustomerTest extends TestCase {
    
    	public CustomerTest(String name) {
    		super(name);
    	}
    
    
    	public void titleTest() throws Exception{
    		System.out.println("Inside titleTest()..");
    		Customer customer = new Customer();
    		customer.setTitle("Mr.");
    		assertEquals("Title is Mr.", "Mr.", customer.getTitle());
    		assertEquals("Title should be String", 12, customer.getTitle());
    		assertNotNull("Title should not be null", customer.getTitle());
    
    	}
    
    	public void suffixTest() throws Exception{
    		System.out.println("Inside suffixTest()..");
    		Customer customer = new Customer();
    		customer.setSuffix("Sr.");
    		assertEquals("Suffix is Sr.", "Sr.", customer.getSuffix());
    		assertEquals("Title should be String", 12, customer.getSuffix());
    		assertNotNull("Title should not be null", customer.getSuffix());
    	}
    
    	public static Test suite() {
    	   return new TestSuite(CustomerTest.class);
    	 }
    
    	public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
    	}
    }
    I am using junit 3.8.1.
    I am running it as Junit Test. But i am getting some errors as following.


    Code:
    junit.framework.AssertionFailedError: No tests found in com.exit41.orderperfect.customeridentification.test.unittest.CustomerTest
    	at junit.framework.Assert.fail(Assert.java:47)
    	at junit.framework.TestSuite$1.runTest(TestSuite.java:263)
    	at junit.framework.TestCase.runBare(TestCase.java:127)
    	at junit.framework.TestResult$1.protect(TestResult.java:106)
    	at junit.framework.TestResult.runProtected(TestResult.java:124)
    	at junit.framework.TestResult.run(TestResult.java:109)
    	at junit.framework.TestCase.run(TestCase.java:118)
    	at junit.framework.TestSuite.runTest(TestSuite.java:208)
    	at junit.framework.TestSuite.run(TestSuite.java:203)
    	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
    	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)
    can anybody help me with this?

    Thanks,
    Sonali.

  • #2
    The method signatures need to match

    Code:
    public void test*() [throws Exception]
    so your named your methods wrongly.

    Joerg

    Comment


    • #3
      If you do want to name your tests however you like you can using JUnit4 and the @Test annotation.
      Last edited by karldmoore; Aug 27th, 2007, 03:55 PM.

      Comment


      • #4
        Thanks, I changed method names. I started it with test and it is working well now.

        Thanks,
        Sonali.

        Comment

        Working...
        X