Thoughts of MahipalInnovate to simplify |
|
Tuesday Jun 10, 2008
I18n of Junit Testcases
I always believe that Maximum I18n testing should be done before build release to QA. To do that I keep finding out various way to do more and more i18n testing during development. In that I stuck with this idea of creating Junit testcase for I18n testing. Then I relize it would be good to make Junit testcase itself I18n. So that input to Junit testcase can be non-english data. It will check the flow of non-english data in application. I have done that for one of module for my product. i.e Portal Server. ObjectiveI18n'ed JUnit test case input which will help in doing I18n testing in JUnit.How to do it?I18n input of Junit Test case
Exampleex. Let me give you example of one of CMS junit testcaseTestcase to create category. source : CategoryTest.java Before : testCategoryCreation{ String categoryName="TestCategoryCreation"; ...(code to test creation) ... } In this testcase category name "TestCategory" is hardcoded in java
program. I have removed this hardcoding and load this value from
Resource Bundle. Now : CategoryTest.java One new class variable needs to be added. ResourceBundle rb;
As shown above, resource bundle will be load once for Test program and it will be used by all the testcases within it. so now when developer run this testcases in english environment and it will work as it was previously. Now How to leverage this testcase for I18n testing. Base Testcase Program has to implement this Interface.
How to provide Localized value for TestcaseThen we need to create New Test program for language in which you want to do I18n testing which will have only one method selectLocale(). ex. "ja".CategoryJaTest extends CategoryTest { Now on whenever Junit framework will be executed. It will execute this test program also and since locale set to "ja" . Resource bundle for japanese will be loaded. which will be used to test all the tests of CategoryTest since it is extended by CategoryI18nTest. You can create Category<locale>Test java program , ResourceBundle(properties) file for all the language in which I18n testing needs to be done. (phir milenge ... (cu later))
Posted at 04:06PM Jun 10, 2008 by Mahipalsinh Rana in Personal | Comments[1] |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Hi,
I am writing junit testcases & stuck with void return type methods.
Please provide input.Below is my code.
public void read() throws SQLException
{
Connection conn=null;
try {
conn=getConnection();
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from dbo.login");
while(rs.next())
{
System.out.println(rs.getString(1));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
conn.close();
}
}
Thanks in advance.
with regards,
Tejas
Posted by tejas on June 11, 2008 at 02:39 PM IST #