Mocking a MockMultipartFile does not work in multipart request in spring-test 5.3.2 Affects: spring-test 5.3.2

See sample project here

If you check out the test, you can see I am spying a MockMultipartFile to force it to throw an IOException on getInputstream() here

This works fine in spring-test 5.3.1 but does not work in 5.3.2. I confirmed this by excluding spring-test from spring-boot-starter-test and directly importing spring-test 5.3.1, which resolves the issue.

Throwing a breakpoint in the controller method you can see that the MockMultipartFile is not a mock when on 5.3.2

Possibly caused by https://github.com/spring-projects/spring-framework/commit/d82cb15439c1c9d4100daabb275e0eb102a877bc as fix for https://github.com/spring-projects/spring-framework/issues/26166

Comment From: rstoyanchev

This is a duplicate of #26261. I tried with the sample and switching to 5.3.3 snapshots makes the test pass.

Comment From: austinarbor

@rstoyanchev i tried adding https://repo.spring.io/snapshot/ to the build.gradle but can't seem to get 5.3.3-SNAPSHOT imported. is there anything else i need to do?

Comment From: rstoyanchev

I also added:

ext['spring-framework.version'] = "5.3.3-SNAPSHOT"

Comment From: austinarbor

Looks like using http instead of https in the repo URL was my problem. Confirming bug is fixed in 5.3.3-SNAPSHOT

Comment From: izeye

This seems to be meant to be closed with the "status: duplicate" label.

Comment From: snicoll

Thanks for the nudge Johnny.