function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Victor EcheverríaVictor Echeverría 

Validate if object was inserted in DB

I'm having an issue with a test class and I think the error is that it's not inserting some setup objects that are required. How can I make sure that the objects are inserted? Is there a method like System.Assert to achieve this?
sravan velamasravan velama
Hi  Victor,

Yes, there is a methods called System.assertEquals) and System.assertNotEquals). Which are used check whether the inserted value matches with expected value in test classes.
For example:-
Account a = new Account();
a.Name = 'Test';
insert a;
System.assertEquals'Test',a.Name); // This method checks whether the inserted value matches with the expected value and throws a error, If inserted value doesn't matches with expected value.
System.assertNotEquals)//This method works vice-versa of System.assertEquals()
For more information follow the below link
.https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_system.htm