On Apr 8, 2010, at 6:08 AM, Erwan de FERRIERES wrote:
the only thing I see with the tests, is that test files should not
be at the same directory level as the source code.
I think that we should have :
<component>/src/test
and not :
<component>/src/org/ofbiz/<component>/test
the only point in this change, is when doing code coverage, it's
looking for coverage on the tests, which is not the best idea.
But maybe someone with more knowledge would be able to tell if I'm
right or not...
For naming the tests, the only thing we need with JUnit 3.8, is to
have the test prefixed with test. It's true for minilang tests as
well.
I remember having a discussion with someone based on that folder
structure for tests; having come from a place where we did just that I
was now in a place where they saw benefit in keeping the testing code
in close proximity to the source code it is testing. I just took a
look at a few other projects in Apache to see what they have done ...
what I typically found was that they follow this folder structure as
well and they typically name their test classes "TestXXX".
Me thinks if we are going to spend anytime reorganizing our unit tests
and establishing an Ofbiz best practice, we probably should just agree
on it before I do anything. Here is the only real information I could
find from old trusty google ...
"JUnit 3.8 suggests the following naming conventions:
Test Case Class: Named as [classname]Test.java, where "classname" is
the name of the class that is being tested. A test case class define
the fixture to run multiple tests. A test case class must be subclass
of junit.framework.TestCase.
Test Method: Named test[XXX], where "XXX" is any unique name for this
test. A test method name should be prefixed with "test" to allow the
TestSuite class to extract it automatically. A test method must be
declared as "public".
Test Suite: Can be named any way you want to. But Eclipse uses
AllTests.java as the name. A test suite is a collection of test cases."
The proposal I put forth is as such --
1) Move the junit test source into a folder structure as indicated by
Erwan
2) Rename the test classes to follow the JUnit 3.8 naming convention
above
3) Start separate discussion on splitting our "build" target into
"compile" and "compile-tests" ensuring that test code is not included
in the standard ofbiz application jar (ie. ofbiz-party.jar becomes
ofbiz-party.jar and ofbiz-party-test.jar or something similar).