how to test the value of a variable in one method of a class which is not returned in the testcase(junit)?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Archana_Subramanian
Posted On:   Wednesday, March 14, 2007 06:14 AM

Suppose this is the class to be tested .. public ResultSet recentSubmission() throws SQLException { Connection con = null; ResultSet rs=null; try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:acme","RIUser","Demo"); PreparedStatement ps= con.prepareStatement("SELECT SUBMISSSION_GUID FROM SUBMISSION WHERE SUBMISSSION_GUID = 143"); rs=ps.executeQuery(); return rs; } catch(Exception e) { e.printStackTrace(); } //con.close(); return rs; } How to test the connection(con) and preparedStatement(ps)values   More>>

Suppose this is the class to be tested ..

			
public ResultSet recentSubmission() throws SQLException {

Connection con = null;
ResultSet rs=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:acme","RIUser","Demo");
PreparedStatement ps= con.prepareStatement("SELECT SUBMISSSION_GUID FROM SUBMISSION WHERE SUBMISSSION_GUID = 143");
rs=ps.executeQuery();
return rs;
}
catch(Exception e)
{
e.printStackTrace();
}
//con.close();
return rs;
}



How to test the connection(con) and preparedStatement(ps)values in the junit Testcase?    <<Less

Re: how to test the value of a variable in one method of a class which is not returned in the testcase(junit)?

Posted By:   Dharma_S  
Posted On:   Wednesday, April 4, 2007 10:05 AM

Hi Archana,

well that can't be possible. Logically speaking with out getting the connection and preparedstatement objects you will get a resultset object with a null value. And in the mean time if at all there is problem in getting the connection or PreparedStatement objects you will get an exception which will be caught in your application and placed in the log files which you can always see and say whether a testcase was passed/failed.

Thanks
About | Sitemap | Contact