In test class, you have to use System.assertEqual() method when you want to verify (static method of the System class) the result of your tests to be sur your Apex code works like you want.
This is a example of an Apex test class :
@isTest
private class ApexClass_TEST {
static Account anAccount;
static String theName;
static void init(){
theName = 'My account';
/** Account **/
anAccount = new Account(
Name = theName
);
insert anAccount;
}
static testMethod void myTest() {
init();
Test.startTest();
Account insertedAccount = [
SELECT Id, Name
FROM Account
WHERE Id = :anAccount.Id
];
System.assertEquals(theName, insertedAccount.Name);
}
}
I don't know why test method are static but it's said in the documentation. :)
In test class, you have to use System.assertEqual() method when you want to verify (static method of the System class) the result of your tests to be sur your Apex code works like you want.
This is a example of an Apex test class :
I don't know why test method are static but it's said in the documentation. :)
Let me know if you understand my example.
Aurélien