You need to sign in to do that
Don't have an account?
jeremy_r
Setting up tests
The examples for unit testing seem to be mixing the unit tests in with the domain classes. I don't really like this, as I like to keep test classes separate from the domain classes being tested. The problem seems to be that if you sepratate your test methods into test classes, Apex expects your test classes to be covered, which turns into an infinite loop.
Can anyone share what they feel may be a clean and scalable way to do testing with Apex code?
thanks
Jeremy
Can anyone share what they feel may be a clean and scalable way to do testing with Apex code?
thanks
Jeremy
Does that make sense?
Here's what one of our test classes look like:
public class TestUpdateEscalationGroupTrigger {
static testMethod void escalationGroupAssignedFromOwningQueue() {
Group queue = [select id, name from Group where name = 'CSSD' and type = 'Queue'];
System.assert(queue.id != null);
Case c = new Case();
c.ownerId = queue.id;
insert c;
c = [select id, escalation_group__c from case where id = :c.id];
System.debug(c.Escalation_Group__c);
System.assert(c.Escalation_Group__c == queue.name);
}
}
I also remember someone mentioning that each class has to have at least one test that covers it. Would this mean that TestXXXCase class would have to be covered?
Message Edited by jeremy_r on 08-28-2007 02:27 PM
As to your second question, I don't know if it'll complain that your "test" classes must themselves have tests, we haven't done a deployment yet. That would certainly be a major pain for us.
You can create another APEX class file, and include all of your tests in there (with all of the methods inside the class marked as testMethod)
Then, inside the class you wish to test, make a new testMethod, and have it call all of the methods you've created in the other class.
When you run the tests, the APEX engine will ignore the class with only test methods defined - you dont have to test the test methods! :)
Code:
Message Edited by sduda on 08-28-2007 04:18 PM
Code: