无法使用Gradle Integration从CLI运行基于驱动程序的测试

时间:2018-11-16 11:08:18

标签: corda

我已经在我的CorDapp项目的src / integrationTest / kotlin / com.example.IntegationTest目录下定义了基于驱动程序的测试:

class IntegrationTest {
private val nodeAName = CordaX500Name("NodeA", "", "GB")
private val nodeBName = CordaX500Name("NodeB", "", "US")

@Test
fun `run driver test`() {
    driver(DriverParameters(isDebug = true, startNodesInProcess = true)) {
        // This starts three nodes simultaneously with startNode, which returns a future that completes when the node
        // has completed startup. Then these are all resolved with getOrThrow which returns the NodeHandle list.
        val (nodeAHandle, nodeBHandle) = listOf(
                startNode(providedName = nodeAName),
                startNode(providedName = nodeBName)
        ).map { it.getOrThrow() }

        // This test will call via the RPC proxy to find a party of another node to verify that the nodes have
        // started and can communicate. This is a very basic test, in practice tests would be starting flows,
        // and verifying the states in the vault and other important metrics to ensure that your CorDapp is working
        // as intended.
        Assert.assertEquals(nodeAHandle.rpc.wellKnownPartyFromX500Name(nodeBName)!!.name, nodeBName)
        Assert.assertEquals(nodeBHandle.rpc.wellKnownPartyFromX500Name(nodeAName)!!.name, nodeAName)
    }
}
}

如果我们尝试从命令行使用gradle integrationTest执行测试,那么如何确保IntegrationTest成功执行?

如果使用Inteliij IDE进行尝试,则Junit测试将按预期与适当的测试报告/日志一起工作。

1 个答案:

答案 0 :(得分:1)

要确保实际运行集成测试,您需要使用clean参数:

./gradlew clean integrationTest

此命令的输出并不总是使您清楚已经运行了哪些测试。您可以使用--info标志使它显示更多信息:

./gradlew clean integrationTest --info