If you use firewall contexts, be sure to set the context to the firewall name in the test environment.
The firewall name is the default context for each firewall.
firewalls:
main:
context: main
...
See https://symfony.com/doc/current/reference/configuration/security.html#firewall-context