Create mock data based on view

Related products: Software Factory

At this moment the Software Factory does not support creating mock data based on views. This means that functionality that is based on a view cannot be covered by unit tests. I’m not sure if it is, but a work around could be to fill all the tables on which the view depends on with mock data, but this could get very time consuming and not necessary if you don’t want to test the view itself. 

If it would be possible to create mock data based on views, then the Software Factory can for example:

  • Rename the existing view
  • Create a mock table based on this view, with the original name
  • add the mock data

 After the unit test has completed, the mock table can be dropped and the view renamed to it’s original name.

Maybe the solution above is a bit blunt. The following solution might be cleaner:

  • Alter the current view and generate a query which unions the mock data values. 
  • Test the unit test
  • Alter the view and add the original views sql query statement.


Hi Bram,

Could this be an alternative?: 

Nevertheless, good idea 😄

This would add ALOT of complexity in our situation as we are using external tables (and views on top of those).