Closed tudvari closed 5 years ago
I am not an expert of Spock but could it be that setupSpec is executed before test event? Can you try https://github.com/lordofthejars/nosql-unit#support-for-jsr-330
Hi,
I try it a several ways, unfortunately didn't help yet. I became the same error message. Last version of my Test:
static Config config
@Shared ModelMapper entityMapper
@Shared Datastore datastore
@ClassRule static InMemoryMongoDb inMemoryMongoDb = newInMemoryMongoDbRule().build();
@Rule static MongoDbRule embeddedMongoDbRule = newMongoDbRule().defaultEmbeddedMongoDb("device1");
def setupSpec() {
File configFile = new File(ClassLoader.getSystemResource("test-config.yaml").getFile())
config = new ConfigReader<Config>().parse(configFile.toURI(), "UTF-8", System.getenv(), Config.class)
entityMapper = new ModelMapperImpl()
}
@UsingDataSet(withSelectiveLocations = @Selective(identifier = "device", locations = ["deviceData.json", "deviceModelData.json", "clientData.json", "vehicleData.json"]), loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
def "getDevice not found"() {
given:
DatabaseOperation<MongoClient> dbOps = embeddedMongoDbRule.getDatabaseOperation();
Morphia morphia = new Morphia();
datastore = morphia.createDatastore(dbOps.connectionManager(), "device1");
Caused by: java.lang.IllegalStateException: There is no EmbeddedMongo rule with default target defined during test execution. Please create one using @Rule or @ClassRule before executing these tests.
Ok, I will check on code why this is exception is thrown. Probably it is a problem with Spock integration nor a bug in your test nor in nosqlunit
Thanks a lot, that would be awesome :)
Upgrading spock-core from 1.1-groovy-2.4 to 1.2-groovy-2.4 solved this issue for me.
Thanks, I would try it tomorrow.
It's working with the proposal of guima. Thank's for your help.
Hi,
I would like to ask a little help. I tried to use the nosql-unit with a Groovy and Spock. Unfortunately it doesn't work, could you help me pls? With Java and Junit almost the same code works.
With Java:
With Groovy:
If you try this, I became this error message:
Thanks in advance.
BR, Tibor