+ Start a Discussion

Test Coverage

When I run the test below, I get a message that the List has no rows for assignment.  When I manually run the query I get a single row returned.  

private class AssetItemTriggerHandlerTest {

 static testMethod void AssetItemTriggerTest() {

  //getting any valid Asset
        Asset testAsset = [select Id, SD_Account_Number__c, Name, Status, PurchaseDate, Renewal_Date__c,
        from Asset where Status='Regular' limit 1];    
        update testAsset;  

You need to insert the test data before you run that query.  Because you are running an API version greater than 24.  You can get around this by enabling SeeAllData for your test, but that is the wrong way to do it.