corda - 无法使用 gradle integrationTest 从 CLI 运行基于驱动程序的测试
问题描述
我在我的 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 测试将按预期工作,并带有适当的测试报告/日志。
解决方案
为确保集成测试实际运行,您需要使用以下clean
参数:
./gradlew clean integrationTest
此命令的输出并不总是清楚地表明已经运行了哪些测试。--info
您可以使用以下标志使其显示更多信息:
./gradlew clean integrationTest --info
推荐阅读
- python - 我需要使用函数 python 交换矩阵中的元素
- android - ClassCastException:无法将 MediaMetadataRetriever 强制转换为 AutoCloseable
- list - How to organize and show in a ListView my Map
> - python - How can I mock functions that are called by async code?
- kubernetes-helm - Helm charts creating from python API
- java - SpringBoot Maven 项目未在数据库中创建表
- python - 使用面板数据Python中的标识符使用非空值替换缺失值
- tensorflow - 子类化 tf.keras.Model 时创建 tf.keras.add 层
- google-apps-script - Google Script - 更改电子邮件中的链接格式
- python - Numba printing information regarding Nvidia driver to python console when using its Cuda module. How to suppress this?