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.
1 Answer 1
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
src
directory they havemain
andtest
.