Emmanuel Lecharny schrieb: > On 6/4/10 10:10 AM, Stefan Seelmann wrote: >> Emmanuel Lecharny wrote: >> >>> On 6/4/10 1:03 AM, Stefan Seelmann wrote: >>> >>>> Emmanuel Lecharny wrote: >>>> >>>> >>>>> On 6/3/10 11:04 PM, Stefan Seelmann wrote: >>>>> >>>>> >>>>>> Hi dev, >>>>>> >>>>>> the core-mock module includes some mock implementations of ApacheDS >>>>>> core-api classes (CoreSession, DirectoryService, etc.). It is only >>>>>> used >>>>>> as test dependency in ldif-partition. >>>>>> >>>>>> To get rid of the core-mock module I'd like to suggest to move those >>>>>> classes to src/test/java in core-api. To be able to use the test >>>>>> classes >>>>>> outside of the core-api module we just need to deploy the test jar of >>>>>> core-api. The using module then needs to specify a dependency with >>>>>> classifier "tests", see [1] for details. >>>>>> >>>>>> >>>>>> >>>>> We also had a discussion with Pierre-Arnaud about those unit tests. >>>>> Once >>>>> upon a time, we have had some core-unti and server-unit modules. They >>>>> have been renamed core-intger and server-integ. So far, so good, >>>>> but we >>>>> still have another module called apacheds-test-framework. >>>>> >>>>> We do think that the classes we have in core/server-integ - I mean, >>>>> the >>>>> classes in java/main, not the tests - should be moved to >>>>> apacheds-test-framework. >>>>> >>>>> That being said, we could also move the core-mock into this >>>>> apacheds-test-framework module. >>>>> >>>>> Does it make sense ? >>>>> >>>>> >>>> I'm afraid that won't be possible because this would cause cyclic >>>> dependencies. >>>> >>>> The integ tests and the test framework start up a real directory >>>> service >>>> with real partitions, including an LDIF based config and schema >>>> partition, so they depend on the ldif-partition. >>>> >>>> The mocks are used because we can't start a real directory service in >>>> ldif-partion module for unit tests. >>>> >>>> But we can run the integration tests against the LDIF partition. >>>> >>>> >>> Ok, so we have the exact same problem than with the LDAP API : we had to >>> extract the api tests and put them in ApacheDS just to be able to launch >>> a real server. >>> >>> What about doing the same thing and move all the Ldif-Partition tests >>> out of the ldif-partition module and put them where they can use the >>> real DS ? >>> >>> I mean, tests are not to be close to the part they are testing? >>> >>> thoughts ? >>> >> I think we should distinguish unit tests and integration tests. >> >> Unit tests should be close to the part they are testing. And they should >> not test other components around. Thus it is valid to use mocks. > Absolutely >> The >> tests in ldif-partition are unit tests because they just test that the >> ldif-partition code works, that is that files in the file system are >> created or deleted. So I think these tests are at the right place. >> > So where should we put the mocks ? Core-API as you suggested ? (IMO, if > that solve the problem, then +1)
Yes, this would solve the problem. Another option that also works: as the mocks are only used by the LDIF partition tests we can also move them to src/test/java of ldif-partition. I think that's the better option.
