I have list
and I want to write a dynamic test case based on the lists.
My business logic -
Public listing & lt; Maps & lt; Object, object & gt; & Gt; ListofMap () {List & lt; Maps & lt; Object, object & gt; & Gt; ListofmapObj = New Arrestist & lt; Maps & lt; Object, object & gt; & Gt; (); Maps & Object, Object & gt; Map1 = New Hashmop & lt; Object, object & gt; (); Map1.put ("map1key", "map1value"); Maps & Object, Object & gt; Map2 = New Hashmop & lt; Object, object & gt; (); Map2.put ("map2key", "map2value"); Maps & Object, Object & gt; Map3 = New Hashmop & lt; Object, object & gt; (); Map3.put ("map3key", "map3value"); ListofmapObj.add (map1); ListofmapObj.add (MAP2); ListofmapObj.add (map3); Return catalog; }
My test class -
public class TestCaseCreateListOfMap Testkas increases {Stringbfr strobe = new Stringbfr (a); String name; @Test Public Zero Test - ResultForListOfMap (try {{AddListOfMap obj = new AddListOfMap ()) List & lt; Maps & lt; Object, object & gt; & Gt; Listofmap = obj.listofMap (); (Map & lt; object, object & gt; Show: listofmap) {for (Map. Entry & lt; object, object & gt; entry: map.entrySet ()) {System.out.println (entry.getKey) + "-" + entry getValue ()); StrBuff.append (entry .getKey (+) + "-" + entry.getValue ()); }}} Hold (exception e) {// TODO: exception strBuff.append (e.getMessage ()); } If (strBuff.length ()> gt; {unsuccessful ("+ + + strub"); }}}
Now, as a list of three maps, I need three separate test cases. Is it possible? Please help me on this. Currently I am writing the test method as "testResultsForListOfMap", but I need three separate test cases for this.
Thanks Praveen
To make the test suite in this category and test them the cases are used to add
public class TestCaseDemo {public static test suite} {AddListOfMap obj = new AddListOfMap (); List & lt; Maps & lt; Object, object & gt; & Gt; Listofmap = obj.listofMap (); TestSite Suite = New Test Site ("ABC"); Suite.addTest (new JunitFileTestSuite (listofmap)); Return suit; }
}
public class JunitFileTestSuite TestSuite {secure list & lt; Maps & lt; Object, object & gt; & Gt; Map; Public JunitFileTestSuite (List & lt; Map & lt; Object, Object & gt; & gt; Map) {this.map = map; // Adding recursive cases addTestCases (); } Protected void addTestCases () (for the (Show and object, object, object; gt; listofmap: map) {JunitFileTestCase jftc = new JunitFileTestCase (listofmap); addTest (jftc);}}} public class JunitFileTestCase TestCase extended {safety map & lt; object, object & gt; listofmap; public Junitfailtstcas (map and object, object, object list, flop) {super (); This.listofmap = listofmap; (Map. entry & lt; object, object & gt; Entry: listofmap.entrySet ()) {System.out.println (entry.getKey) + "-" + + Entry Shti .getValue ()); SetName (entry.getKey ()); }} Safe void runTest throws throws (executeTestCase (listofmap);} // should not execute the last zero. Exceptions (maps and objects, object & gt; filename) exception {StringBuffer sbf = new StringBuffer (); (Map. Entry & lt; Object, Object & gt; Entry: listofmap.entrySet ()) {System.out.println (entry.getKey) + "+" + Entry .getValue ()); If (("" + entry.getKey ()). ("Failed") {sbf.append (entry.getKey () + "-" + + entry.getValue ()); }} If (sbf.length ()> gt; {unsuccessful ("+ + sbf)"; }}
}
That's it ... :)
Comments
Post a Comment