testing - Running dynamically created JUnit Tests -


i developing eclipse plugin generates junit test suite dynamically. issue run tests. create package .java, each of them created simple string. want run .java code (junit tests). know junitcore give me possibility, first need instantiate .java classes have been created.

step step:

1.create string .java content.

  string tests = "public class mytests extends testcase {";   ... 

2.create .java in external workspace same content string

3.instantiate .java classes.

mytest mytestclass = new mytest(); ?????????? 

4.run test suite.

junitcore junit = new junitcore(); result result = junit.run(mytestclass); 

now @ step 3. question.

example: example contains testcase class implements 1 dummy test

string stests = "package test.dqspm;\n\n";     stests += "import junit.framework.testcase;\n";     stests += "\npublic class mttests extends testcase {\n\n";      stests += "\tpublic void test1 (){\n" +             "\t\t" + "asserttrue(true);" + "\n" +             "\t}\n";      stests += "\tpublic static test suite(){" +              "\t\treturn new testsuite(mytests.class);" +             "\t}\n";     stests += "\tpublic static void main (string[] args){" +             "\t\tjunit.textui.testrunner.run(suite());" +             "\t}\n";     stests += "}\n";  /* creates .java file in workspace of project tested  * stests string content */ ipackagefragment testpackage; //this object java project package testpackage.createcompilationunit("mytests.java",stests, true, null);  /* instantiate .java classes */ ¿?¿?¿?¿?  /* running tests */ junitcore junit = new junitcore(); result result = junit.run(mytests.class); 

after need run mytests.java , results show them customized.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -