Hi,
I am trying to run automated JUnit tests from ant to check package
dependencies. The tests I am trying to right are very similar to
the 'Dependency Constraint' test in the documentation. My test case
contains the following two tests,
public void testDependencyConstraint1()
{
//Step 1. Create new DependencyConstraint
DependencyConstraint constraint = new DependencyConstraint();
//Step 2. Add packages to the DependencyConstraint
JavaPackage CmaUtil = constraint.addPackage("bridges.cma.util");
JavaPackage CmaView = constraint.addPackage
("bridges.cma.view");
//Step 3. Set package Dependencies
CmaView.dependsUpon( CmaUtil );
//Step 4. Analyze
m_jdepend.analyze();
//Step 5. Perform assertions
// This should be true because bridges.cma.view package does
// use the bridges.cma.util package.
assertEquals( "Dependency mismatch", true,
m_jdepend.dependencyMatch( constraint ) );
}
public void testDependencyConstraint2()
{
//Step 1. Create new DependencyConstraint
DependencyConstraint constraint = new DependencyConstraint();
//Step 2. Add packages to the DependencyConstraint
JavaPackage CmaUtil = constraint.addPackage( "bridges.cma.util" );
JavaPackage CmaView = constraint.addPackage
("bridges.cma.view");
//Step 3. Set package Dependencies
CmaUtil.dependsUpon( CmaView );
//Step 4. Analyze
m_jdepend.analyze();
//Step 5. Perform assertions
// This should be false because bridges.cma.util package does
// not use the bridges.cma.view package.
assertEquals( "Dependency mismatch",false,
m_jdepend.dependencyMatch( constraint ) );
}
I initialise the m_jdepend in the setUp() method to parse my source
code,
m_jdepend.addDirectory( "./build/src/java" );
Both tests should pass because bridges.cma.view package uses the
bridges.cma.util package but the reverse is not true. In both cases
the the dependencyMatch returns false when it should only return
false for testDependencyConstraint2().
I have double checked the packages that are parsed after the analyze
() method( I iterated through the collection of packages and dumped
the package names) and the packages in my constraint are being
analyzed. Have I missed something or is this a bug? The example
looked fairly simple and I believe this should work
Thank You
Cody