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
Kelsey Jolitz 20Kelsey Jolitz 20 

Unable to Pass Apex Tests for Security Superbadge Section 2

Unable to pass tests for 2nd Challenge for Security Specialist Superbadge.

Using Apex Test Execution -- 

Error Message: 
System.QueryException: List has no rows for assignment to SObject

Log Details (from Dev Console):
10:57:19:010 SOQL_EXECUTE_BEGIN [132]|Aggregations:0|SELECT Id, Name FROM Profile WHERE Name = :tmpVar1
10:57:19:015 SOQL_EXECUTE_BEGIN [133]|Aggregations:0|SELECT Id FROM UserRole WHERE Name = :tmpVar1

Details of my configuration - 

Roles: Field Sales, Inside Sales, Sales Executive User 

Active Users: 
Cordero, Samantha with Role as Field Sales and Profile as Field Sales User
Myself as the System Admin

Public Group:
Project Managers - Field Sales Role, User = Samantha Cordero

*Test Opportunities are owned by Samantha Cordero*

Sharing Settings:
Opportunities 
Org. Wide Defaults
Internal Access = Private
External Access = Private
Sharing Rules
(Opportunity: StageEQUALSClosed Won) AND (Opportunity: TypeEQUALSExisting Customer - Upgrade) Group: Project Managers Read Only
Owner in Role: Field Sales shared with Role: Inside Sales Read/Write
Owner in Role: Sales Executive User shared with Role: Inside Sales Read Only
I am not sure what other information to provide but this all seems relevant to the error I received in the log in the Developer Console. This is driving me crazy because I feel like I have done every possible thing with no successful outcome, several times. 

Is there something wrong with my configuration settings? Is there something else I should be looking at?

Very lost at this point. Should I try uninstalling the package and re-installing? Or...

Please advise, thanks!
 
Andrew GAndrew G
Based on the error shown, I would check the variable that is being passed to your SOQL queries in your code.  Throw a System.debug in for the variable just before your SOQL and run the debug logs.

If the variables look correct, then check that you have those Profiles and Userroles actually created in your environment.  Note that profiles and user roles are queried from you environment, not created in your test class.

If that all looks good, try the SOQL from teh developer console and check the results.

Regards
Andrew