Git Product home page Git Product logo

Comments (5)

f-lopes avatar f-lopes commented on July 28, 2024

Thanks for your report.
Could you please elaborate on this error?

All this library does is map POJO fields to HTTP request parameters. This "handler" error seems to be related to a missing handler mapping. Is your handler (ie. PostMapping annotated method) discovered? -> Can you see the /myapp/path path in the startup logs? Spring logs the discovered mappings under the org.springframework.web.servlet.HandlerMapping.Mappings logger.

Also, did you register your controller with the MockMvc instance you use in your tests?

[...]
mockMvc = MockMvcBuilders.standaloneSetup(new UserController())
[...]

from spring-mvc-test-utils.

SingingBush avatar SingingBush commented on July 28, 2024

The test class is annotated with @WebMvcTest(MyController.class) and I autowire MockMvc. It's correctly picking up other methods which are being tested with standard MockMvcRequestBuilders.get but for some reason this method that has @PostMapping({"/path"}) just isn't playing ball.

I've been trying to recreate the problem in a test on spring-mvc-test-utils (hence PR #131) but it may just be a problem my end as you say. I'll try updating the logger and see what's happening there

from spring-mvc-test-utils.

f-lopes avatar f-lopes commented on July 28, 2024

Thanks for your reply 👍
Don't hesitate if you need more help 🙏

from spring-mvc-test-utils.

SingingBush avatar SingingBush commented on July 28, 2024

This has turned into a real pita. All tests for methods with @GetMapping work fine but if I test anything with @PostMapping then mockMvc fails to find a handler:

Handler:
             Type = null

this is the same whether I write the test using MockServerHttpRequest.post or MockMvcRequestBuilderUtils.postForm.

from spring-mvc-test-utils.

f-lopes avatar f-lopes commented on July 28, 2024

Thanks for your feedback. Feel free to share some code if you need help :)

from spring-mvc-test-utils.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.