# AppSourceCop Error AS0058
Only use AssertError in Test Codeunits
## Description
Only use AssertError in Test Codeunits.
## Remarks
AssertError must be used only in test codeunits, because it creates its own transaction scope. This can lead to unexpected behaviors when used in production code.
For more information about the usage of AssertError, see:
 ../devenv-al-simple-statements#asserterror-statements
 Testing the application overview<../devenv-testing-application>
 TransactionModel property<../properties/devenv-properties>
## Related information
AppSourceCop Analyzer<appsourcecop>
Get Started with AL<../devenv-get-started>
Developing Extensions<../devenv-dev-overview>
codecop-aa0161

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/appsourcecop-as0058, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/analyzers/appsourcecop-as0058/
