Source_System_Configuaration__c systemconfig;


            systemconfig=[SELECT Id, System_Id__c, Source_Confidence__c FROM Source_System_Configuaration__c WHERE System_Id__c = '01siebel01'];           

in test class my query has throwing list has no rows but i executed the same query from developer console,it not showing that exception,here System_Id__c is unique,in any circumstances it will throw only one record.can u please tel me,what might be the problem?! thanks in advance.

  • Are you using @SeeAllData annotation for Test Class? – Devendra Oct 12 '16 at 11:08
  • no for method i had used testMethod infront of the method and @istest infront of the class\ – Satya Oct 12 '16 at 11:10
  • You can add SeeAllData annotation to your test class, which will access Org Data in Test Class. The other work around is not to use SeeAllData and create your own data in Test Class. – Devendra Oct 12 '16 at 11:27
  • You should really almost never use Test.isRunningTest checks. It should be an absolute last resort. – Adrian Larson Oct 12 '16 at 12:51

Check annotation SeeAllData

Annotate your test class or test method with IsTest(SeeAllData=true) to open up data access to records in your organization.

So, If you give your Test Class (@SeeAllData=True) annotation then the test class can access Org Data.

Example with SeeAllData:

private class TestDataAccessClass {

    // This test accesses an existing custom Setting
    static testmethod void myTestMethod1() {
        // Query an existing Custom Setting Data in the organization. 


SeeAllData annotation solves your problem. But, It is best practise to create test data for your test class, instead of accessing data from Org. This will make your test class Org Data Independent, as test class will not be depend on Org data.

Example without SeeAllData:

private class TestDataAccessClass {

    static void createTestData() {
        // Create test data here

    // This test accesses an existing account. 
    // It also creates and accesses a new test account.
    static void myTestMethod() {
        // Execute Test Code
        // Write Assert Statements
| improve this answer | |
  • 2
    @SeeAllData=True is strongly not recommended to use. Instead there is annotation @testSetup for method that creates test data – Vladyslav K Oct 12 '16 at 12:45
  • @VladyslavKushney Yes, Thats Right. I have given both the options in my answer and mentioned that best practice is to create your own data in test class. – Devendra Oct 12 '16 at 12:53

Try by inserting dummy data for Source_System_Configuaration__c in test class

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.