You need to sign in to do that
Don't have an account?
Shannu
System.AssertException: Assertion Failed on MassReassignopportunity Class
Code is fine but during deployment Test class is showing faulre.
System.assert(controller.optyList.size()>0);
controller.optyList[0].selected = true;
controller.helperRecord.Assign_to__c = UserInfo.getUserId();
controller.Assign();
Could some one help me on this
System.assert(controller.optyList.size()>0);
controller.optyList[0].selected = true;
controller.helperRecord.Assign_to__c = UserInfo.getUserId();
controller.Assign();
Could some one help me on this
The System.AssertException you are encountering suggests that the assertion System.assert(controller.optyList.size()>0) is failing in your test class. This means that the optyList in the controller does not have any records, and therefore, the size is not greater than zero.
To address this issue, you need to ensure that the optyList in the controller is populated with at least one record before executing the Assign() method. Here's an updated version of your test class with an example of how to create and add an opportunity to the optyList: In this updated test class, we first create an Opportunity record and insert it into the database. Then, we add the Opportunity to the opportunityList in the controller. This ensures that the optyList has at least one record, satisfying the assertion System.assert(controller.optyList.size()>0).
Hope this helps !
Thank you.
The System.AssertException is thrown when an assertion in your test class fails. In your case, the assertion `System.assert(controller.optyList.size()>0)` is failing, indicating that the size of the `optyList` is not greater than zero as expected.
To troubleshoot this issue, you need to identify why the `optyList` is empty in your test scenario. Here are a few possible reasons:
1. Test Data: Ensure that you have properly created test data in your test class. It's possible that there are no opportunities created or associated with the test data, resulting in an empty `optyList`. Make sure you have relevant test data created before invoking the code under test.
2. Filtering or Criteria: Check if there are any filters or criteria in the code that restrict the opportunities retrieved for the `optyList`. Review the code in your `MassReassignopportunity` class to see if there are any conditions that could cause the `optyList` to be empty. Adjust the test data or code accordingly to meet the required conditions.
3. Dependencies: If the opportunities in the `optyList` are dependent on other records or data, ensure that you have properly created and associated the required data in your test class. Sometimes, missing or incorrect data dependencies can cause the `optyList` to be empty.
Review the above possibilities and adjust your test class accordingly to ensure that the `optyList` is populated with the expected opportunities. Additionally, you can add debug statements or use the Salesforce Developer Console to inspect the state of the data and variables during the test execution to identify any potential issues.
if this helps you please mark it as a best answer,
Thanks!