本文介绍了摇篮测试依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个项目,项目A和项目B.两个都写在Groovy和使用gradle这个作为他们的编译系统。

I have two projects, project A and Project B. Both are written in groovy and use gradle as their build system.

A计划要求的项目B.
这适用于编译和测试code两者。

Project A requires project B.This holds for both the compile and test code.

如何配置该项目A的测试类可以访问项目B的测试类?

How can I configure that the test classes of project A have access to the test classes of project B?

推荐答案

您可以通过测试配置曝光的测试类,然后定义上配置的testCompile依赖。

You can expose the test classes via a 'tests' configuration and then define a testCompile dependency on that configuration.

我有该程序的所有Java项目,这罐子所有测试code:

I have this block for all java projects, which jars all test code:

task testJar(type: Jar, dependsOn: testClasses) {
    baseName = "test-${project.archivesBaseName}"
    from sourceSets.test.output
}

configurations {
    tests
}

artifacts {
    tests testJar
}

后来,当我有测试code我想项目之间访问我用

Then when I have test code I want to access between projects I use

dependencies {
    testCompile project(path: ':aProject', configuration: 'tests')
}

这是Java;我假设它应该常规正常工作。

This is for Java; I'm assuming it should work for groovy as well.

这篇关于摇篮测试依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 07:45