3

There seem to be a few fundamental mistakes here. The main one seems to be that you aren't thinking about object instances correctly, but let me start with another one first. Looking at the following fragment Contact cOld = new Contact( FirstName = 'TestFirst', LastName = 'TestLast', Recipe__c ='1', Email = 'Test@test.com', ); insert cOld; ...


3

It is a bind variable, so it needs to be used with colon. Also it should be declared outside the test method. Moreover, when you use @IsTest annotation on the method, you do not need to add testMethod modifier (which is deprecated). Finally, SeeAllData is false by default for test class, so it is not necessary to add this annotation to the class: @IsTest ...


3

The golden rule of unit testing is you only gain coverage for code that is executed as part of running a test method. You do have multiple test methods, but only one of them (testMethod1()) actually executes any code in your controller. The rest of your test methods simply insert new records using regular DML (and thus they do not contribute any code ...


1

You run into the Mixed DML error when you try to update setup objects and non-setup objects in the same context. Most of the SObjects we can work with fall into the "non-setup" category, and the User SObject is the most common one you'll find people using in the "setup" category. In most cases, we need to explicitly create our test data. ...


1

All of this code: for(Integer i=0;i<srList.size();i++){ if (srList.get(i).isSuccess()){ srList.get(i).getId(); }else if (!srList.get(i).isSuccess()){ // DML operation failed Database.Error error = srList.get(i).getErrors().get(0); String failedDML = error.getMessage(); recsToInsert.get(i);//failed record ...


Only top voted, non community-wiki answers of a minimum length are eligible