Search code examples
javatestingmockitoapache-commons-fileupload

How to write unit tests with commons-fileupload?


I'm working in a framework that uses commons-fileupload.

Now I need to write unit test classes. My doubt is how to write mock tests if ServletFileUpload is not an interface? There are another way to test my classes?

Yesterday I wrote unit tests using mockito for Servlet Parts, and it's easy. But I can't think how to write tests for commons-fileupload.


Solution

  • You could go back to basics and hand roll your mock object by either wrapping or extending and overriding. Sometimes its easier to not depend on a mocking framework for everything.

    Mocking Mocking and Testing Outcomes