2

My new company has never had unit testing, but have finally been persuaded to introduce it.

They have chosen Google test and, for some reason, want to run the unit tests from within Eclipse (where I, personally, would run it from the command line, preferably as some sort of CI and/or check-in process).

With hundreds, possibly thousands, of individual source files, each dealing with one class or a group of related functions, we need to have one test script per source file, but do we really need one Eclipse project, or can we just have as single, humungous project which runs each of the test scripts?

Management insist that the unit tests be runnable from within Eclipse.

4
  • 1
    You can run tests both from within eclipse and command-line. Aug 18, 2015 at 8:41
  • Yup, that's my plan (+1). Ideally, I want to be able to test each file individually, but that seems like a lot of Eclipse projects to create. Aug 18, 2015 at 8:46
  • 2
    You should create a test class for every source class you have, so you could run only the tests for that class if you want (while developing), but put all classes (source and tests) inside the same eclipse project Aug 18, 2015 at 8:49
  • 1
    Look for example at the elasticsearch github repo where inside the src directory they have main and test. Aug 18, 2015 at 8:52

1 Answer 1

2

Usally Unit-Tests are included in the Project, typically under a different source-folder e.g.

src ==> for your Code test ==> for your Unit-Tests.

If you use Maven, you will get a structure similar to that.

Those tests can be run per Command line and from Eclipse ot-of-the-box, if the Tests are JUnit-Tests. Eclipse has a nice GUI for that, afaik its included in every Eclipse: Eclise & Junit

Sometimes, people put their Tests in a seperate Project, so for each Eclipse-Project you have you create a _test-Project for the Unit-Tests. This might be an advantage, when you run the Tests seperate from you build, e.g. every 3 hours or so.

It is very uncommon to make one Project for each Class - you'll end easily up with thousands of Test-Projects.

For how to use Google-Test with Eclipse this might help: https://stackoverflow.com/questions/3951808/using-googletest-in-eclipse-how

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.