Assume that I have multiple java projects, all of them use maven: Project A and Project B
-
Project A is a library
-
Project B is an application which uses Project A
Both projects are developed simultaneously. New requirements from Project A are fulfilled with a new release of Project B.
I mostly tested my code manually which - as expected - yielded less than optimal code coverage and therefore quality.
I'm therefore currently looking into using Junit to write tests for my projects. Since Project A mostly defines interfaces, I would have to - at least I believe so - write implementations of these classes in the test code.
As I already have implementations of those interfaces defined in Project B I figured I could use Project B as test
dependency in Project A, which at first glance would make perfect sense as nearly all features of Project A are used in those implementations, as I would (at least for now) not develop a feature in Project A that is not used in Project B (Keep in mind: this might change for future projects e.g. a newly created Project C, which might also depend on Project A).
On the other hand this would create some sort of circular dependencies. In Project B's pom.xml
I would define a regular dependency on Project A, while Project A would have a dependency on Project B in the test
-scope.
Therefore the following questions:
- Is this even technically possible or would I run into issues with the circular dependencies right from the start or at a later point in time? (I believe I've seen someone doing something similar, where they had to define the correct version of Project A in Project A's
<dependencyManagement>
section to make sure the current code is used while testing and not the version defined in Project B. I can't find it anymore though, so I can't verify this, but I remember being confused on why they would define their own projects version in that section. Edit: I believe I found it again, but it seems to be something else, I was propably just kind of confused while researching junit and testing ;) ) - Is it desirable to use a downstream project for classes for a test case or are there issues I could face at a later point in time? (My first thought would be that I'd run into a problem as soon as I replace Project A with a third party dependency in Project B, therefore loosing all my test cases for Project A)
Aucun commentaire:
Enregistrer un commentaire