Home > Software engineering >  Intellij doesn't seem to be able to run my spock test
Intellij doesn't seem to be able to run my spock test

Time:09-14

I just created a new spring boot project and am trying to add spock testing. Here is my spock test:

package com.heavyweightsoftware.farragut.server.pojo.account

import spock.lang.Specification

import java.time.ZonedDateTime

class AccountTest extends Specification {
    Account account;

    static Account getAccount() {
        Account result = new Account()

        return result;
    }

    void setup() {
        account = getAccount()
    }

    def "getStartTime should never be null"() {
        when: "retrieving a start date"
        ZonedDateTime start = account.getStartTime()

        then: "should never be null"
        start != null
    }
}

When I run it, I get the following error

C:\Users\ThomH\.jdks\openjdk-16.0.1\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:63091,suspend=y,server=n -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:C:\Users\ThomH\AppData\Local\JetBrains\IntelliJIdea2021.2\groovyHotSwap\gragent.jar -javaagent:C:\Users\ThomH\AppData\Local\JetBrains\IntelliJIdea2021.2\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2021.1\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2021.1\plugins\junit\lib\junit5-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2021.1\plugins\junit\lib\junit-rt.jar;C:\Users\ThomH\workspace\farragut-server\build\classes\java\test;C:\Users\ThomH\workspace\farragut-server\build\classes\groovy\test;C:\Users\ThomH\workspace\farragut-server\build\classes\java\main;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-web\2.7.3\9e36c7517c4f872b69d0665e1dd46bd6d83c43b7\spring-boot-starter-web-2.7.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-test\2.7.3\ce5a11117ac6c92d38ce071ff2273799862659b7\spring-boot-starter-test-2.7.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-data-jpa\2.7.3\23f7118584200cf9edd43140dc6252679047bee0\spring-boot-starter-data-jpa-2.7.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\2.7.3\6b0c093af667bf645cd5f49372e2a2540ae2855f\spring-boot-starter-2.7.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-devtools\2.7.3\ea46ce1fc8c0581f2455dcc43a11768660d87388\spring-boot-devtools-2.7.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.codehaus.groovy\groovy-sql\3.0.9\a70eef193799ed892958ca00c6eda4f8710f656f\groovy-sql-3.0.9.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.spockframework\spock-core\2.1-groovy-3.0\2bd689be193cb26f42692eeef070e6669bebae3e\spock-core-2.1-groovy-3.0.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.codehaus.groovy\groovy\3.0.10\b92c72a758f468e64b55e38abe06afa873decdba\groovy-3.0.10.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.junit.jupiter\junit-jupiter-api\5.9.0\a44f7eba3ea214f6ec87ad9fccd3b2ac4681a4\junit-jupiter-api-5.9.0.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.hamcrest\hamcrest-core\2.2\3f2bd07716a31c395e2837254f37f21f0f0ab24b\hamcrest-core-2.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-json\2.7.3\38c88404d68926aaf6c0914199e8c5e766946de2\spring-boot-starter-json-2.7.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-tomcat\2.7.3\7a5998baaa05d5e7a9af7194a21f2ac3512ba7a0\spring-boot-starter-tomcat-2.7.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework\spring-webmvc\5.3.22\519d86b7ac9b8b6bb54739eb4eb73dc13a263b28\spring-webmvc-5.3.22.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework\spring-web\5.3.22\fdab9b8d8df2e6a8fb90f2481c361bcf2c129567\spring-web-5.3.22.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.junit.jupiter\junit-jupiter\5.8.2\5a817b1e63f1217e5c586090c45e681281f097ad\junit-jupiter-5.8.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-test-autoconfigure\2.7.3\42924dceee5636b5c12ed36011cc333b40e1f756\spring-boot-test-autoconfigure-2.7.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-test\2.7.3\34d3fbf68aa72beef1515ab4a439c23c8c41280e\spring-boot-test-2.7.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework\spring-test\5.3.22\48375b44c82945e12012ec56dc4090c805b4508b\spring-test-5.3.22.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework\spring-core\5.3.22\661fc01832716c7eedebf995c6841b2f7117c63d\spring-core-5.3.22.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\com.jayway.jsonpath\json-path\2.7.0\f9d7d9659f2694e61142046ff8a216c047f263e8\json-path-2.7.0.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\jakarta.xml.bind\jakarta.xml.bind-api\2.3.3\48e3b9cfc10752fba3521d6511f4165bea951801\jakarta.xml.bind-api-2.3.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.assertj\assertj-core\3.22.0\c300c0c6a24559f35fa0bd3a5472dc1edcd0111e\assertj-core-3.22.0.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.hamcrest\hamcrest\2.2\1820c0968dba3a11a1b30669bb1f01978a91dedc\hamcrest-2.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.mockito\mockito-junit-jupiter\4.5.1\f81fb60bd69b3a6e5537ae23b883326f01632a61\mockito-junit-jupiter-4.5.1.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.mockito\mockito-core\4.5.1\ed456e623e5afc6f4cee3ae58144e5c45f3b3bf\mockito-core-4.5.1.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.skyscreamer\jsonassert\1.5.1\6d842d0faf4cf6725c509a5e5347d319ee0431c3\jsonassert-1.5.1.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.xmlunit\xmlunit-core\2.9.0\8959725d90eecfee28acd7110e2bb8460285d876\xmlunit-core-2.9.0.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-aop\2.7.3\b2806bdfae4cff6b82a174a68984a4cedd2d83f5\spring-boot-starter-aop-2.7.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-jdbc\2.7.3\c5cfc6efad06811d5dd916e86c97989b08575b31\spring-boot-starter-jdbc-2.7.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-jpa\2.7.2\1b8783e98d4199c8fbcb46765fbfce02f41907fe\spring-data-jpa-2.7.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\jakarta.transaction\jakarta.transaction-api\1.3.3\c4179d48720a1e87202115fbed6089bdc4195405\jakarta.transaction-api-1.3.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\jakarta.persistence\jakarta.persistence-api\2.2.3\8f6ea5daedc614f07a3654a455660145286f024e\jakarta.persistence-api-2.2.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.hibernate\hibernate-core\5.6.10.Final\408fd5802391d8e6f619db9d7c6c0e27d49118c2\hibernate-core-5.6.10.Final.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aspects\5.3.22\1fdd8ac7f557ba12bb59086edfe3a9cdf6d918bf\spring-aspects-5.3.22.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.7.3\4c96169e8d71c9c41f07a40d011dbd41898180ac\spring-boot-autoconfigure-2.7.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.7.3\3a8d641077565b7eaec3b2f91d5b83a6800f5895\spring-boot-2.7.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.7.3\a1e4a13b656182ba10b4c0c7848f91cd6f854fdf\spring-boot-starter-logging-2.7.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\jakarta.annotation\jakarta.annotation-api\1.3.5\59eb84ee0d616332ff44aba065f3888cf002cd2d\jakarta.annotation-api-1.3.5.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.30\8fde7fe2586328ac3c68db92045e1c8759125000\snakeyaml-1.30.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.junit.platform\junit-platform-engine\1.8.2\b737de09f19864bd136805c84df7999a142fec29\junit-platform-engine-1.8.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.junit.platform\junit-platform-commons\1.8.2\32c8b8617c1342376fd5af2053da6410d8866861\junit-platform-commons-1.8.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.opentest4j\opentest4j\1.2.0\28c11eb91f9b6d8e200631d46e20a7f407f2a046\opentest4j-1.2.0.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.apiguardian\apiguardian-api\1.1.2\a231e0d844d2721b0fa1b238006d15c6ded6842a\apiguardian-api-1.1.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.13.3\ad2f4c61aeb9e2a8bb5e4a3ed782cfddec52d972\jackson-datatype-jsr310-2.13.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-parameter-names\2.13.3\f71c4ecc1a403787c963f68bc619b78ce1d2687b\jackson-module-parameter-names-2.13.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\2.13.3\d4884595d5aab5babdb00ddbd693b8fd36b5ec3c\jackson-datatype-jdk8-2.13.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.13.3\56deb9ea2c93a7a556b3afbedd616d342963464e\jackson-databind-2.13.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-websocket\9.0.65\bd70dfeb39cc83c6934be24fa377b21e541dbe76\tomcat-embed-websocket-9.0.65.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-core\9.0.65\a24c5f379b2ec343a167a83332b75c37f26b2ae7\tomcat-embed-core-9.0.65.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-el\9.0.65\d278157387e59a5f9b48091dcada22b7c74aed00\tomcat-embed-el-9.0.65.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework\spring-context\5.3.22\fdd59bb4795c7a399e95ec4a5c8b91103e3189fd\spring-context-5.3.22.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aop\5.3.22\2f9f00efbff8432f145ccffeb93e6a1819bac362\spring-aop-5.3.22.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.3.22\866c2022b5fef05b1702f4a07cfa5598660ce08a\spring-beans-5.3.22.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework\spring-expression\5.3.22\c056f9e9994b18c95deead695f9471952d1f21d1\spring-expression-5.3.22.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.junit.jupiter\junit-jupiter-params\5.8.2\ddeafe92fc263f895bfb73ffeca7fd56e23c2cce\junit-jupiter-params-5.8.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.3.22\811ace5e5eb379654ed96fd7844809db51af74a5\spring-jcl-5.3.22.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.36\6c62681a2f655b49963a5983b8b0950a6120ae14\slf4j-api-1.7.36.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\net.minidev\json-smart\2.4.8\7c62f5f72ab05eb54d40e2abf0360a2fe9ea477f\json-smart-2.4.8.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\jakarta.activation\jakarta.activation-api\1.2.2\99f53adba383cb1bf7c3862844488574b559621f\jakarta.activation-api-1.2.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy\1.12.13\35ffee9c24b1c68b08d9207e1a2d3da1add6166\byte-buddy-1.12.13.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy-agent\1.12.13\5a4ed1c2eb9e8d7272b36b2b16757e5c653ab650\byte-buddy-agent-1.12.13.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\com.vaadin.external.google\android-json\0.0.20131108.vaadin1\fa26d351fe62a6a17f5cda1287c1c6110dec413f\android-json-0.0.20131108.vaadin1.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.aspectj\aspectjweaver\1.9.7\158f5c255cd3e4408e795b79f7c3fbae9b53b7ca\aspectjweaver-1.9.7.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jdbc\5.3.22\d50fc708ef9bade1d3fb64d529b8ff8cd5b625ba\spring-jdbc-5.3.22.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\com.zaxxer\HikariCP\4.0.3\107cbdf0db6780a065f895ae9d8fbf3bb0e1c21f\HikariCP-4.0.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework\spring-orm\5.3.22\abcefbf4895a3daf263cf385cc66e924db92d254\spring-orm-5.3.22.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-commons\2.7.2\9547d1234cb380234066aef60129bb2ddfdc6347\spring-data-commons-2.7.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.springframework\spring-tx\5.3.22\d0b3812ab20987a13f3a9ae7b4c54f619e034692\spring-tx-5.3.22.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.glassfish.jaxb\jaxb-runtime\2.3.6\1e6cd0e5d9f9919c8c8824fb4d310b09a978a60e\jaxb-runtime-2.3.6.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.hibernate.common\hibernate-commons-annotations\5.1.2.Final\e59ffdbc6ad09eeb33507b39ffcf287679a498c8\hibernate-commons-annotations-5.1.2.Final.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.jboss.logging\jboss-logging\3.4.3.Final\c4bd7e12a745c0e7f6cf98c45cdcdf482fd827ea\jboss-logging-3.4.3.Final.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\antlr\antlr\2.7.7\83cd2cd674a217ade95a4bb83a8a14f351f48bd0\antlr-2.7.7.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.jboss\jandex\2.4.2.Final\1e1c385990b258ff1a24c801e84aebbacf70eb39\jandex-2.4.2.Final.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\com.fasterxml\classmate\1.5.1\3fe0bed568c62df5e89f4f174c101eab25345b6c\classmate-1.5.1.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.11\4741689214e9d1e8408b206506cbe76d1c6a7d60\logback-classic-1.2.11.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.17.2\17dd0fae2747d9a28c67bc9534108823d2376b46\log4j-to-slf4j-2.17.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.36\ed46d81cef9c412a88caef405b58f93a678ff2ca\jul-to-slf4j-1.7.36.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.13.3\7198b3aac15285a49e218e08441c5f70af00fc51\jackson-annotations-2.13.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.13.3\a27014716e4421684416e5fa83d896ddb87002da\jackson-core-2.13.3.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\net.minidev\accessors-smart\2.4.8\6e1bee5a530caba91893604d6ab41d0edcecca9a\accessors-smart-2.4.8.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.glassfish.jaxb\txw2\2.3.6\45db7b69a8f1ec2c21eb7d4fc0ee729f53c1addc\txw2-2.3.6.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\com.sun.istack\istack-commons-runtime\3.0.12\cbbe1a62b0cc6c85972e99d52aaee350153dc530\istack-commons-runtime-3.0.12.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.11\a01230df5ca5c34540cdaa3ad5efb012f1f1f792\logback-core-1.2.11.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.17.2\f42d6afa111b4dec5d2aea0fe2197240749a4ea6\log4j-api-2.17.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.ow2.asm\asm\9.1\a99500cf6eea30535eeac6be73899d048f8d12a8\asm-9.1.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.junit.vintage\junit-vintage-engine\5.9.0\b4980fe3c30b330ffa118fc1e732c804260d0bf6\junit-vintage-engine-5.9.0.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\com.h2database\h2\2.1.214\d5c2005c9e3279201e12d4776c948578b16bf8b2\h2-2.1.214.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy\1.12.8\aa42edb39e624cbf8a5b33cb5c5e920027cee42b\byte-buddy-1.12.8.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.objenesis\objenesis\3.2\7fadf57620c8b8abdf7519533e5527367cb51f09\objenesis-3.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.junit.platform\junit-platform-testkit\1.8.2\43c593ad99a975588d56b501fd4353065facebfc\junit-platform-testkit-1.8.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.jetbrains\annotations\20.1.0\2fcd1f3225bca0c4a7bc931142076f8c1e80993f\annotations-20.1.0.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.ow2.asm\asm\9.2\81a03f76019c67362299c40e0ba13405f5467bff\asm-9.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\cglib\cglib-nodep\3.3.0\87271c95d5bc9e37e4981c9593ff14d470b6684b\cglib-nodep-3.3.0.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\junit\junit\4.13.2\8ac9e16d933b6fb43bc7f576336b8f4d7eb5ba12\junit-4.13.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.junit.jupiter\junit-jupiter-engine\5.8.2\c598b4328d2f397194d11df3b1648d68d7d990e3\junit-jupiter-engine-5.8.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\org.junit.platform\junit-platform-launcher\1.8.2\c334fcee82b81311ab5c426ec2d52d467c8d0b28\junit-platform-launcher-1.8.2.jar;C:\Users\ThomH\.gradle\caches\modules-2\files-2.1\com.sun.activation\jakarta.activation\1.2.2\74548703f9851017ce2f556066659438019e7eb5\jakarta.activation-1.2.2.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 com.heavyweightsoftware.farragut.server.pojo.account.AccountTest
Connected to the target VM, address: '127.0.0.1:63091', transport: 'socket'
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

org.junit.runners.model.InvalidTestClassError: Invalid test class 'com.heavyweightsoftware.farragut.server.pojo.account.AccountTest':
  1. No runnable methods

    at org.junit.runners.ParentRunner.validate(ParentRunner.java:525)
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:102)
    at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:84)
    at org.junit.runners.JUnit4.<init>(JUnit4.java:23)
    at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
    at org.junit.internal.requests.ClassRequest.createRunner(ClassRequest.java:28)
    at org.junit.internal.requests.MemoizingRequest.getRunner(MemoizingRequest.java:19)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:50)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

Here's my build.gradle

plugins {
    id 'org.springframework.boot' version '2.7.3'
    id 'io.spring.dependency-management' version '1.0.13.RELEASE'
    id 'groovy'
    id 'java'
}

group = 'com.heavyweightsoftware.farragut'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-devtools'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testRuntimeOnly 'com.h2database:h2:2.1.214'

    // mandatory dependencies for using Spock
    implementation 'org.codehaus.groovy:groovy:3.0.10'
    testImplementation platform("org.spockframework:spock-bom:2.1-groovy-3.0")
    testImplementation "org.spockframework:spock-core"
    testImplementation "org.junit.jupiter:junit-jupiter-api:5.9.0"
    testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.9.0"

    // optional dependencies for using Spock
    testImplementation "org.hamcrest:hamcrest-core:2.2"   // only necessary if Hamcrest matchers are used
    testRuntimeOnly 'net.bytebuddy:byte-buddy:1.12.8' // allows mocking of classes (in addition to interfaces)
    testRuntimeOnly "org.objenesis:objenesis:3.2"      // allows mocking of classes without default constructor (together with ByteBuddy or CGLIB)

    // dependencies used by examples in this project
    implementation "org.codehaus.groovy:groovy-sql:3.0.9"
}

tasks.named('test') {
    useJUnitPlatform()

    testLogging {
        events "passed", "skipped", "failed"
    }
}

I found a bunch of similar issues that were resolved variously. Tried all of the things like

  • Make certain the groovy directory is marked as a test sources root
  • Invalidate cache and restart
  • Run unit tests using IntelliJ IDA instead of gradle

Also found a similar intelliJ bug, but wanted to try here before going to intelliJ.

Ideas?

CodePudding user response:

You could try to tell IntelliJ to run the tests via Gradle, this has the added advantage that the execution will match what you see in CI, especially if you have some additional config on the test task. It is a bit slower though.

There was a bug IDEA-274589 in an older IntelliJ version, so upgrading to the fix version or newer will help.

  • Related