Search code examples
javamockingbddxlsapache-poi

Is it wise to use mocking in BDD test cases?


We are going to implement a small java application with BDD, which reads an MS excel sheet using POI of apache.org and prints some text based on that excel to the STDOUT. We agreed that the simplest solution would be to create a test.xls for each BDD test case.

There was another idea, which is that we should mock the POI library calls and expectations for testing. The reasoning behind this idea is that we don't want to test the POI, and waste test time on using it in every test case. Additionally file access can be tricky on different operating systems.

Is it wise to use mocking in such cases?


Solution

  • I've never been a big fan of mocking but it does make sense in some instances.

    I think Apache POI is stable enough and you can properly stub it out. The important thing to ask is if you are testing interaction with POI? If you are, then you can't mock it out.

    Since you say you not testing interaction with POI then go ahead.