Error when running Corda flow tests from IntelliJ

隐身守侯 提交于 2019-11-30 14:11:37

问题


When I run Corda flow tests from IntelliJ, the tests fail with the following errors:

QUASAR WARNING: Quasar Java Agent isn't running. If you're using another instrumentation method you can ignore this message; otherwise, please refer to the Getting Started section in the Quasar documentation.

and

java.lang.IllegalStateException: Missing the '-javaagent' JVM argument. Make sure you run the tests with the Quasar java agent attached to your JVM. See https://docs.corda.net/troubleshooting.html - 'Fiber classes not instrumented' for more details.

How can I fix this?


回答1:


Corda flows need to be instrumented using Quasar before they are run, so that they can be suspended mid-execution.

To achieve this in IntelliJ, you need to:

  • Create a run config for your tests
  • Open the run config and change the VM options to -ea -javaagent:PATH-TO-QUASAR-JAR
    • In the CorDapp example and templates, quasar.jar is located at lib/quasar.jar, so you'd use -ea -javaagent:../lib/quasar.jar

Alternatively, you can edit the default JUnit run config to use the Quasar javaagent by default, avoiding you having to do this every time you pick a new test to run.




回答2:


This is a basic error that you get if you don't set Quasar, you need to select your test-> go to Intellij top bar-> Run -> Edit Configurations and then set up like this photo in VM options:




回答3:


From template readme

We recommend editing your IntelliJ preferences so that you use the Gradle runner - this means that the quasar utils plugin will make sure that some flags (like -javaagent - see below) are set for you.

To switch to using the Gradle runner:

Navigate to Build, Execution, Deployment -> Build Tools -> Gradle -> Runner (or search for runner) Windows: this is in "Settings" MacOS: this is in "Preferences" Set "Delegate IDE build/run actions to gradle" to true Set "Run test using:" to "Gradle Test Runner" If you would prefer to use the built in IntelliJ JUnit test runner, you can run gradlew installQuasar which will copy your quasar JAR file to the lib directory. You will then need to specify -javaagent:lib/quasar.jar and set the run directory to the project root directory for each test.



来源:https://stackoverflow.com/questions/47411363/error-when-running-corda-flow-tests-from-intellij

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!