mercredi 4 février 2015

How do I mock a class marked final and has a private constructor using jMockit

I would like to write some state based tests using JMockit to mock up CSVRecord. The problem is that JMockit is final (which means I have to use a mocking framework like JMockit) and CSVRecord's constructor has package private visibility.


Since it is package private, I can't call new CSVRecord(arg, arg, ...), which means my mock will never get instantiated.


Does JMockit have a way to deal with this scenario?


note: JMockit or Mockito are the only frameworks we use on this project. No other framework will be acceptable. My strong preference is to use state based testing, but I might warm up to behavioral testing if state based approach is not available here.


Aucun commentaire:

Enregistrer un commentaire