Forum chevron_right Corda Topics chevron_right CorDapp Development chevron_right Having trouble to run Flow test

  • Creator
    Topic
  • #10195
    qiancheng fan
    Participant

    I am studying corda and trying to write flow test for my corda app, but when I run the test I have this error:

    “Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)
    java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)”

    I do have setted up my environment according to the tutorial and my corda app can compile and run nomally, but it just can not start flow test, any suggestion will be helpful to me.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #10206
    Thiago Viana
    Participant

    It seems to be a problem with the reference/version of mockito and corda. Did you try using a different version? An older or a newer one?

    It would help posting a pice of your code (also the dependence definition).

    #10210
    qiancheng fan
    Participant

    1

    #10211
    qiancheng fan
    Participant

    Hi, I’m not sure how to change the mockito version, I thought it is included in corda testing library, I tried to change the cordaVersion and cordaCoreVersion in the file:”constants.properties” to 4.7 and 4.8 but still not work. The current version file is this:

    cordaReleaseGroup=net.corda
    cordaCoreReleaseGroup=net.corda
    cordaVersion=4.9
    cordaCoreVersion=4.9
    gradlePluginsVersion=5.0.12
    kotlinVersion=1.2.71
    junitVersion=4.12
    quasarVersion=0.7.13_r3
    log4jVersion=2.17.1
    platformVersion=10
    slf4jVersion=1.7.30
    nettyVersion=4.1.68.Final
    
    And the dependency definition here is:
    dependencies {
        testCompile "junit:junit:$junit_version"
    
        // Corda dependencies.
        cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version"
    
        cordaRuntime "$corda_release_group:corda:$corda_release_version"
        testCompile "$corda_release_group:corda-node-driver:$corda_release_version"
    
        // CorDapp dependencies.
        cordapp project(":contracts")
        // Token SDK dependencies.
        cordaCompile "$tokens_release_group:tokens-money:1.1"
        cordaCompile "$tokens_release_group:tokens-workflows:$tokens_release_version"
    }
    
    And the code of the test I run is just the template test here: 
    https://github.com/corda/cordapp-template-java/blob/release-V4/workflows/src/test/java/com/template/FlowTests.java
    It should be my setting's issue but I really have no clue how to fix it.
    #10212
    Thiago Viana
    Participant

    Try adding Mockito’s dependency (maybe the latest one):

    Something like this:

    dependencies {

    compile “org.mockito:mockito-core:$mockito_version_number”

    }

    Where $mockito_version_number is actually the version. =D

    #10213
    qiancheng fan
    Participant

    I added this and tried many versions but the error is still there. But still thank you for your advice.

    #10271
    Peter Li
    Keymaster

     

    Hi Qiancheng,

    Unfortuntely I cannot recreate your error, but I look into the dependencies and find a way for you to look at your own project and check if the dependencies were downloaded correctly.

    At the gradle panel (the right side of the IntelliJ), there is a search dependencies button. Click that, and at the top left select the workflows package, then search for Mockito. You should be able to see if the dependencies are successfuly downloaded to your project.

    The mockito denpendencies is included in the node itself, so you should not need to manually add dependencies yourself.

     

    Peter Li – R3

    #10276
    qiancheng fan
    Participant

    Hi,

    I find the mockito-core:2.28.2  dependency at this location: workflows/corda-node-driver:4.9/corda-test-utils:4.9/corda-test-common:4.9/mockito-core:2.28.2

    But it shows a error with hint “conflict with 2.18.3”, this might be the reason why I have this issue but I am not sure how to fix it. Is there any suggestions for that? many thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Subscribe to our newsletter to stay up to date on the latest developer news, tools, and articles.