packaging app issues

  • 1
  • Problem
  • Updated 4 years ago
  • Solved
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 = [
            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 = [
            select id, name 
            from skuid__Page__c 
            where skuid__Module__c = :InstallScript_RECON.MODULE_NAME
        ];
       
        pageAssignments = [
            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 = [select 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;
      }
      System.assertNotEquals(null,exCaught);
      
    }

   
}
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
  • nervous

Posted 4 years ago

  • 1
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Are you sure that the trigger is active?
Photo of JD Bell

JD Bell, Senior Product Engineer

  • 2,996 Points 2k badge 2x thumb
The code coverage statistics are notoriously unreliable. What really matters is the code coverage statistics when verifying your change set.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
@ 74%!!!! SO CLOSE!!! hehhehehe
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Pat, Did you reach the mythical 75%?
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
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.

Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Ping me back channel and let's git'r fixed.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Thanks for all the community support here.  We hope the trade show this week is wildly successful!