This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 198549 - test case cannot find symbol
Summary: test case cannot find symbol
Status: RESOLVED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: JUnit (show other bugs)
Version: 7.0
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Yulia Novozhilova
URL: http://localhost:8080
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-12 10:26 UTC by raviparekh
Modified: 2011-08-09 12:25 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description raviparekh 2011-05-12 10:26:13 UTC
when i run test case i got the following error
while same is working with eclips.
Java Web application.
junit 4.8.2

Compiling 1 source file to E:\cheapCaribbean\build\test\classes
E:\abc\test\junit\com\abc\data\RoomManagerTest.java:50: cannot find symbol
symbol  : method getNameByID(int)
location: class com.abc.data.RoomManager
        String result = instance.getNameByID(id);
1 error
E:\abc\nbproject\build-impl.xml:1063: The following error occurred while executing this line:
E:\cheapCaribbean\nbproject\build-impl.xml:260: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)

RoomManagerTest.java

public class RoomManagerTest {
    
    public RoomManagerTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }

   

    /**
     * Test of getNameByID method, of class RoomManager.
     */
    @Test
    public void testGetNameByID() {
        System.out.println("getNameByID");
        int id = 5840;
        RoomManager instance = new RoomManager();
        String expResult = "";
        String result = instance.getNameByID(id);
        assertEquals(expResult, result);
     
    }
}
Comment 1 raviparekh 2011-05-12 10:28:07 UTC
RoomManager.JAVA

public String getNameByID(int id){
        return HibernateUtil.currentSession().createCriteria(Room.class)
               .setProjection(Projections.property("title"))
               .add(Restrictions.eq("id", id)).list().get(0).toString();
        
}
Comment 2 raviparekh 2011-05-26 11:30:13 UTC
when i run this program after creating new project it works fine but create project using existing source gives me same error.
Comment 3 Yulia Novozhilova 2011-08-09 12:25:02 UTC
I created java project with existing sources on NetBeans 7.0.1. I used your code, the only difference is that getNameByID(int id) returns empty string by default. The test case run successfully without any error. Closing the issue as worksforme. 
Please feel free to reopen in case if you still experience the problem. Please attach the whole files, may be there is some error in the java code that causes the issue.