I'm trying to write a unit test for a post install script class, a class that implements InstallHandler interface. I'm testing two cases: 1- No previous version is defined, for that I just use this:
PostInstallClass postinstall = new PostInstallClass(); Test.testInstall(postinstall, null);
This is working fine.
2- A previous version exists, but for that I'm getting an error System.QueryException: List has no rows for assignment to SObject
PostInstallClass postinstall = new PostInstallClass(); Test.testInstall(postinstall, new Version(1, 0));
So how to test this second case? How to simulate a test environment where a previous version of a managed package exists? Thanks.
List<SObject>and then handle the 0-results case appropriately.