Questions tagged [webtestclient]
36 questions
10
votes
1 answer
WebTestClient throws "No qualifying bean ... as autowire candidate"
I currently wrote a put request I wanted to test via WebTestClient. I followed some tutorials and adapted my case to it. Testing the request results in an error:
"NOSuchBeanDefinitionException: No qualifying bean of type…

letsgetraw
- 193
- 1
- 10
8
votes
2 answers
WebTestClient returning IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread
The following function:
private Boolean canDoIt(Parameter param) {
return myService
.getMyObjectInReactiveWay(param)
.map(myObject -> myService.checkMyObjectInImperativeWay(myObject))
.block();
}
is working fine at runtime, but…

Marco Lackovic
- 6,077
- 7
- 55
- 56
8
votes
3 answers
SpringBoot test fails with 'No bean named 'webHandler' available'
I am trying to run SpringBoot Webflux tests but am getting error No bean named 'webHandler' available
I was trying to follow the Spring test docs for webtestclient
The offending line seems to be in setup()
public WebTestClient…

likejudo
- 3,396
- 6
- 52
- 107
3
votes
1 answer
How to specify a specfic port number for Spring WebTestClient
I have a locally running rest endpoint I am attempting to communicate with using Spring WebClient. As a first step for testing purposes, I am trying to use Spring WebTestClient. My local rest endpoint runs on a specific port (lets say 8068). My…

Timothy Clotworthy
- 1,960
- 2
- 19
- 42
3
votes
1 answer
How to use Spring's WebTestClient to check for a string in Kotlin?
I am trying to use the WebTestClient to check a Controller that returns a string. But for some reason I get an error.
I use Kotlin so I tried to apply the Java examples I have found to it but I can't figure out how to do it right. What am I…

Apollo
- 1,296
- 2
- 11
- 24
2
votes
1 answer
Having multiple request IPs in Spring WebTestClient
I'm introducing Bucket4J in my Spring Web application. A basic test setup can be found…

nykon
- 504
- 4
- 18
2
votes
2 answers
Fast api TestClient post list of files
I am trying to test fastapi router that get List of files. In html request using JS its working but I need to test it. I am using TestClient from fastapi, when I am trying so send list I get status code 422 so I go which documentry and try dict but…

גל בורביע
- 31
- 1
- 4
2
votes
1 answer
WebTestClient is null when autowired in a @SpringBootTest
My Spring Boot application runs on version 2.4.2. I'm trying to setup an integration test for a user registration. This test class extends from the AbstractIntegrationTest which defines some static setup.
When starting the test, webTestClient is…

Robert Strauch
- 12,055
- 24
- 120
- 192
2
votes
1 answer
WebTestClient with get() and requestBody not available
I have an application where one of the api is defined with Get method. It also expects request body which then gets mapped to POJO. I am trying to test this controller using webTestClient. But I do not see an option to send request body with get()…

Mayur
- 21
- 3
2
votes
1 answer
How to test Server Sent Events API (written in Spring 5 Webflux), when it is necessary to perform action to generate new event?
I am trying to test my SSE API in the way explained in the following tutorial https://docs.spring.io/spring/docs/current/spring-framework-reference/testing.html#webtestclient-stream .
Unfortunately, it doesn't work for me. To generate next event it…

Dystyria
- 63
- 4
1
vote
1 answer
How to test using StepVerifier a Flux coming from a Controller using WebTestClient in Kotlin?
In Kotlin, I tried to test a simple @RestController using StepVerifier.
@GetMapping("/helloInt")
fun helloInt(): Flux {
return Flux.range(1, 3).delayElements(Duration.ofMillis(300))
}
The test is here:
@Test
fun…

moldovean
- 3,132
- 33
- 36
1
vote
1 answer
"could not resolve view" with `@PreAuthorize` and `WebTestClient`
I'm getting this rather weird bug in a test. My controller has the following method:
@Operation(
summary = "Add a new quote",
operationId = "v1AddQuote",
description = "",
responses = [
…

Haf
- 375
- 1
- 3
- 13
1
vote
3 answers
How to fetch response using WebTestClient
I am new to Reactive programming and having trouble testing. I have a very simple scenario,
an Entity:
class SimpleEntity{
@Id
int id;
String name;
}
a related repository:
class SimpleEntityRepository extends JpaRepository

Murtaza Hasan
- 183
- 1
- 15
1
vote
1 answer
How to add request attributes to a WebTestClient / WebClient?
I looked around but it seems as if there is no suitable solution for a problem I am not alone with: Why am I not able to add attributes to a WebClient (or WebTestClient respectively) request? Whenever I try something like:
var respSpec =…

du-it
- 2,561
- 8
- 42
- 80
1
vote
1 answer
Repository inserts don't work in SpringBootTest with WebTestClient
I am converting a spring boot application to use webflux by making the endpoints reactive one at a time. Most of the (Spock) tests worked fine, but the ones where I autowire the JPA repository in the test to insert data do not. The repository is…

Samuel Lindblom
- 812
- 1
- 6
- 22