Questions tagged [micronaut-test]
23 questions
3
votes
0 answers
Share Micronaut context between tests
Is it possible to share Micronaut context between tests?
By using @MicronautTest annotation in Spock, context is created new for every test class.
This has negative side effects when combined with possible…

piotrd
- 31
- 1
2
votes
0 answers
Micronaut gradle test failing to start on every port
Currently I am using sudo ./gradlew clean build -x testto build and nohup java -jar to run the main application in my ec2 console. And it runs successfully.
But when I am trying to run tests(annotated with @MicronautTest) with sudo…

suvodipMondal
- 656
- 10
- 27
2
votes
2 answers
Setting Test MongoDBContainer with Junit 5 and Micronaut
Trying to setup Test MongoDBContainer with Junit 5 and micronaut, instead of staring the MongoDB at the random port on a test environment it is using the application.yml configuration.
application.yml
micronaut:
application:
name:…

San Jaisy
- 15,327
- 34
- 171
- 290
1
vote
1 answer
How Do I Unit Test Micronaut Error Handlers?
There are two methods in my Controller, the POST controller:
@Post
HttpResponse> post(@Body String designJson) throws JsonProcessingException {
Publisher response =…

SenorPez
- 45
- 1
- 4
1
vote
1 answer
How to use test-resources in micronaut project with postgres, flyway an jooq
I generated new micronaut project with cli:
mn create-app --lang java check-test-resources --features data,flyway,postgres,test-resources,jooq
This is my build.gradle:
plugins {
id("com.github.johnrengelman.shadow") version "7.1.2"
…

Błażej Gruszka
- 21
- 3
1
vote
0 answers
Micronaut custom context in test using @Factory
I'm trying to find any analogue of spring's @ContextConfiguration annotation in micronaut framework
Is there any way to run unit test in micronaut using custom application context?
My project is a library without main class.
I have @Factory with…

user3696568
- 11
- 1
1
vote
0 answers
rollback hibernate reactive transaction
Is it possible to rollback the hibernate reactive transaction when using micronaut data hibernate reactive? Let's say we are writing a test to create a user in the db. We would like to rollback that transaction after the test completes.
Annotating…

JerryThePineapple
- 63
- 8
1
vote
1 answer
Overriding Configuration properties with test container in Micronaut not working
Test container configuration
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Testcontainers
public abstract class TestContainerFixture {
@Container
protected static final GenericContainer mongoDBContainer;
protected static final…

San Jaisy
- 15,327
- 34
- 171
- 290
1
vote
1 answer
How to Mock a Declarative Client in Micronaut?
I have Class in which I call a method from a declarative client. But for my test I don't want it to call the actual URL. Instead I want to Mock it. How can I do that as it is not a class but an Interface annotated with @Client?
Example code:- here.…

Puneet
- 45
- 8
1
vote
0 answers
How to Mock a Client Interface in Micronaut for Server which is used in Server StartupEvent
I have a @Client annotated interface which is used to access a particular URL and fetch some data when my Application starts in a OnApplicationEvent(ServerStartupEvent event) method. The problem is when I use @Micronaut Test, it instantiates the…

Puneet
- 45
- 8
1
vote
0 answers
Micronaut spock test issues with embedded ActiveMQ Artemis
I'm trying to use Micronaut-jms to integrate ActiveMQ Artemis into my application. Everything worked perfectly until I started writing unit tests.
The issue I'm facing is that since my test's are annotated with @MicronautTest when I run a test the…

maun
- 134
- 1
- 1
- 13
0
votes
3 answers
micronaut yaml configuration: special character in default value
This is what I'm having problems with in my application.yml file:
url: ${DATASOURCE_URL:jdbc:postgresql://localhost:5432/postgres}
It seems to treat it like it should cut it at the last colon:
Message: Invalid JDBC URL [5432/postgres]. JDBC URLs…

eis
- 51,991
- 13
- 150
- 199
0
votes
1 answer
How to mock an instance method on injected instance of the class under test?
I am trying to mock an instance method within a real object which is injected within my Test class in spock and I am using Micronaut (with Java) for writing my application. It is as follows:
class MyTestClass extends Specification {
@Subject
…

suvodipMondal
- 656
- 10
- 27
0
votes
1 answer
Why Micronaut Test closed the MongoClient connection
I'm about testing using MongoDB. Instead of Micronaut Test Resources I'm using local hosted docker container for database (I prefer to see the result).
Many my tests depends on MongoDB but some throws that error:
17:34:09.134…

frynet
- 1
- 2
0
votes
0 answers
JUnit - Micronaut Value annotation is not working for the class I running the test
Hi I am trying to right test cases for a class in micronaut with JUnit. The class extends an abstract class AbstractShippingService which is something like this:
@Singleton
public abstract class AbstractShippingService {
…

suvodipMondal
- 656
- 10
- 27