How to reuse another project's test classes

If you would like to reuse a project's test classes from another project, you can add project("X").test.compile.target to the test.with clause of your project.

Example


define "A" do
  package(:jar)
end

define "B" do
  compile.with project("A")
  test.with project("A").test.compile.target  # <---- HERE
  package(:jar)
end
  • No labels

2 Comments

  1. This will work for the compile task; but it will fail for the eclipse task. It generates a non-functional eclipse .classpath file

    1. Aha! The solution for this problem is as follows:

      define "A" do
        package(:jar)
      end
      
      define "B" do
        compile.with project("A")
        test.with project("A").test.compile.target  # <---- HERE
        eclipse.exclude_libs += [project("A").test.compile.target]
      end