Hi, I notice WebFluxTest cannot test with a URL with matrix variable. For example I have a test:

    @Autowired
    WebTestClient webTestClient;
    @Test
    public void exampleTest(){

        webTestClient.get().uri("http://localhost:8080/example/employees/id=1")
                     .exchange()
                     .expectBody().consumeWith(response -> assertTrue(new String(response.getResponseBody(),
                                               StandardCharsets.UTF_8).contains(expected)));
  }

The code to test is:

@Controller
public class Example {

    @GetMapping("/example/employees/{id}")
    @ResponseBody
    public String example(@MatrixVariable("id") int id) {
         ....
    }

And there is a config here:

@Configuration
public class MyConfig implements WebMvcConfigurer {
  @Override
    public void configurePathMatch(PathMatchConfigurer configurer) {
        UrlPathHelper urlPathHelper = new UrlPathHelper();
        urlPathHelper.setRemoveSemicolonContent(false); // <---
        configurer.setUrlPathHelper(urlPathHelper);
    } ...
}

Output:

"status":400,"error":"Bad Request","message":"Missing matrix variable 'id' for method parameter of type int"}

Comment From: rstoyanchev

I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference.

Comment From: rstoyanchev

WebFluxTest is part of Spring Boot so this issue belongs in the Boot issue tracker.

That said some things are not clear or missing. The test class annotations are not visible from the provided snippet. WebFluxTest is primarily for WebFlux testing but the server configuration WebMvcConfigurer is for Spring MVC. As you're connecting over a live port, it's possible that the server is Spring MVC but I think you'll probably need to provide more information about your setup.

Best of all if you could please provide a sample.

Comment From: aCodeRancher

Hi, rstoyanchev, That is true. I am testing a SpringBoot MVC application using WebFluxTest. Here are a list of my dependencies : spring-boot-starter-web,spring-boot-starter-thymeleaf,spring-boot-starter-data-jpa,spring-boot-devtools,spring-boot-starter-test,junit-jupiter-engine,junit-jupiter-api,mockito-junit-jupiter,reactor-core,spring-boot-starter-webflux,reactor-test,junit. The project is a simple one with a class with @SpringBootApplication and the WebMvcConfigurer in my above code snippet.

@WebFluxTest(controllers=Example.class)
 class ExampleTest {

    @Autowired
    WebTestClient webTestClient;

    @Test
    public void example (){
        String expected = String.format("Received request id = [%d]\n", 1);
        webTestClient.get().uri("http://localhost:8080/example /employees/id=1;")
                     .exchange()
                     .expectBody().consumeWith(response -> assertTrue(new String(response.getResponseBody(),
                                               StandardCharsets.UTF_8).contains(expected)));
    }

**Comment From: rstoyanchev**

[@WebFluxTest](https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.html) is for testing WebFlux controllers. So given the above, you are testing the controller with WebFlux infrastructure, so the given Spring MVC config is probably ignored.

This is the part in the Javadoc for testing with a live server:

If you are looking to load your full application configuration and use WebTestClient, you should consider @SpringBootTest combined with @AutoConfigureWebTestClient rather than this annotation. ```

Also see this part in the reference docs.