{"title":"AppSourceCop Error AS0058","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/analyzers/appsourcecop-as0058/","by":"JOP-AL","license":"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.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/appsourcecop-as0058","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Only use AssertError in Test Codeunits.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"AppSourceCop Error AS0058","slug":"appsourcecop-error-as0058","at":0,"chars":696},{"level":2,"title":"Description","slug":"description","at":67,"chars":55},{"level":2,"title":"Remarks","slug":"remarks","at":122,"chars":412},{"level":2,"title":"Related information","slug":"related-information","at":534,"chars":162}],"text":"# AppSourceCop Error AS0058\nOnly use AssertError in Test Codeunits\n## Description\nOnly use AssertError in Test Codeunits.\n## Remarks\nAssertError 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.\nFor more information about the usage of AssertError, see:\n ../devenv-al-simple-statements#asserterror-statements\n Testing the application overview<../devenv-testing-application>\n TransactionModel property<../properties/devenv-properties>\n## Related information\nAppSourceCop Analyzer<appsourcecop>\nGet Started with AL<../devenv-get-started>\nDeveloping Extensions<../devenv-dev-overview>\ncodecop-aa0161"}