Skip to main content

This is a rather urgent requirement as the app is going to be on demonstration at a trade show starting Monday.


Have an app that’s ready to be packaged. This is the second time that this app is being uploaded to the appexchange. The “UnitTests_SkuidModule” test class that was updated from the original tutorial worked the first time going to the appexchange, but not this time. Nothing has been changed.


It fails on the last line of the class. “System.assertNotEquals(null,exCaught);”


@isTest private class UnitTests_SkuidModule { private static testMethod void InstallScript_TestInstallProcess() { Test.startTest(); // Do we have any stored Page Assignments? (We assume we have stored Pages) boolean haveStoredPageAssignments = false; try { StaticResource storedPageAssignments = InstallScript_RECON.GetPageAssignmentsStaticResource(); if (storedPageAssignments != null) { haveStoredPageAssignments = true; } } catch (Exception ex){} // Load up our controller InstallScript_RECON ctl = new InstallScript_RECON(); // Test our install with a null version Test.testInstall(ctl,null); List<skuid__Page__c> pages = ; select id, name, skuid__Layout__c from skuid__Page__c where skuid__Module__c = :InstallScript_RECON.MODULE_NAME ]; List<skuid__Page_Assignment__c> pageAssignments = g select id, Name from skuid__Page_Assignment__c where skuid__Page__r.skuid__Module__c = :InstallScript_RECON.MODULE_NAME and skuid__Context__c = null ]; System.assert(!pages.isEmpty()); System.assertEquals(haveStoredPageAssignments,!pageAssignments.isEmpty()); Integer countPages = pages.size(); Integer countPageAssignments = pageAssignments.size(); // Make a change to the first page we returned skuid__Page__c p = pages 0]; String pageId = p.Id; String originalLayout1 = p.skuid__Layout__c; System.assertEquals(true,p.skuid__Layout__c != null); p.skuid__Layout__c = null; // Now test installing with a previous version. Test.testInstall(ctl, new Version(1,0)); // We should have the same number of pages, and of page assignments pages = s select id, name from skuid__Page__c where skuid__Module__c = :InstallScript_RECON.MODULE_NAME ]; pageAssignments = g select id, Name from skuid__Page_Assignment__c where skuid__Page__r.skuid__Module__c = :InstallScript_RECON.MODULE_NAME and skuid__Context__c = null ]; System.assertEquals(pages.size(),countPages); System.assertEquals(pageAssignments.size(),countPageAssignments); // Make sure that our page whose layout we changed // had its layout changed back to what was in the package p = cselect skuid__Layout__c from skuid__Page__c where Id =:pageId limit 1]; system.assertEquals(originalLayout1,p.skuid__Layout__c); Test.stopTest(); } private static testMethod void PageTrigger_PreventProtectedPageModifications() { // Simulate Dev mode code, // where it should be possible to modify pages in our module InstallScript_RECON.IsRunning = true; skuid__Page__c test1 = new skuid__Page__c( Name = 'UnitTest123'+Datetime.now().getTime(), skuid__Module__c = InstallScript_RECON.NAMESPACE_PREFIX, skuid__Layout__c = '<skuidpage/>' ); insert test1; // Simulate PRODUCTION code, // where it should NOT be possible to modify pages in our module InstallScript_RECON.IsRunning = false; InstallScript_RECON.DevOrgIds = new Set<String>(); skuid__Page__c test2 = new skuid__Page__c( Name = 'UnitTest234'+Datetime.now().getTime(), skuid__Module__c = InstallScript_RECON.NAMESPACE_PREFIX, skuid__Layout__c = '<skuidpage/>' ); Exception exCaught; try { insert test2; } catch (Exception ex) { exCaught = ex; } <b> System.assertNotEquals(null,exCaught);</b> } }

Are you sure that the trigger is active?


That was it. Love how easy that is for you. Thanks Irvin.


My code coverage is way down again. Not sure how it happened. :S


whooooooooosh … 


really hoping I can reduce those lines of code easily. I’m certain those 388 lines had some code coverage.


Really odd. I have a test for the class but it’s letting me test with it.


The code coverage statistics are notoriously unreliable. What really matters is the code coverage statistics when verifying your change set.


@ 74%!!! SO CLOSE!!! hehhehehe


Pat, Did you reach the mythical 75%?


I have except now there is one class where I keep this message.



It’s got this compile error which doesn’t make sense as their is nothing on line 37.



Ping me back channel and let’s git’r fixed.


Thanks for all the community support here.  We hope the trade show this week is wildly successful! 


Reply