0

How can I run the same Junit test on several different projects? These projects are known to contain the same classes with the same features etc.

I want to avoid copying the test class to every project.

basically I want to run the same tests on all their projects (they got the tests from the start) ... so student1 has a project with class A, student 2 has his/her project folder with class A and I want to run my "ATester" on both their projects automatically. The cheapest way of course seems to simply copy my test class in all their projects and just run them through some java code calling a runner (or in a shell script) ... but I was simply wondering if there isn't a beautiful solution to this (been trying to do this in Java with dynamic class loading, but it always seems to come down to the fact that even if I load class A from a different path, the runner keeps using the local version - I need a local version in my 'master', because otherwise my test class won't compile).

It seems to me that my problem boils down to ... what if the class to run with JUnit runclasses needs a class in a different place (i.e. path) ... how can I specify that (from code, not from a shell)

dve845
  • 1
  • 2
  • If you can, take the common classes and make them into their own project, The other projects use it then as dependency. This way you avoid the duplicate classes (which can be a nightmare to maintain) and have all tests in one place. – Rhayene May 24 '17 at 12:48
  • I can't because they are all versions of the same class made by different students ... basically I want to run the same tests on all their projects (they got the tests when they started to build there classes) – dve845 May 24 '17 at 14:31
  • Ah, this information is important. Best add that to your question. – Rhayene May 24 '17 at 14:36
  • Looks like a simple classpath problem to me. Take a look at this question: https://stackoverflow.com/questions/2235276/how-to-run-junit-test-cases-from-the-command-line – Daniel Figueroa May 25 '17 at 08:23
  • well the test seems to favor the class in his own folder over the one I give him through the classpath – dve845 May 25 '17 at 17:48

0 Answers0