jeudi 7 janvier 2016

Salesforce/Apex, Why is TestDataFactory class included on code-coverage percentage?

Now I'm making Apex test case for clearing code-coverage.

Used normal code following like,

http://ift.tt/1ZcjFhe

TestDataFactory

@isTest
public class TestDataFactory{
    public List<Account> createAccounts(){
        // data create...
        return accounts;
    }
    // data create methods...
    .
    .
    .
}

MyTestClass

@isTest
private class MyTestClass {
    static testmethod void test1() {
        TestDataFactory.createAccounts();
        // Run some tests
    }
    // other testmethods
    .
    .
    .
}

Number of lines of my TestDataFactory class is 100lines, and MyTestClass 100lines is test case logic is already completed code cover.

Therefore, 100 lines / 200 lines. Code coverage is 50%.

Because code coverage of TestDataFactory class is 0%.

How can I solve it?

I'm sorry for poor English. Thank you for reading it.

Aucun commentaire:

Enregistrer un commentaire