80

If we were able to run tests from Visual Studio Code (and from some command line application - like we can build using alc.exe) it would make a massive improvement to the efficiency of development (and probably the uptake in writing and running tests). This presupposes that you have the relevant symbols downloaded and that your tests are truly data-agnostic - I suppose all database transactions would need to be mocked and held in memory - tests could not rely on pre-existing setup data. I'd want the test isolation options to be respected though to optionally persist data between tests. While docker has greatly reduced the overhead of creating an environment to test in running tests or trying to implement some test-driven development process is cumbersome.

Category: Development
STATUS DETAILS
Under Review
Ideas Administrator

Thank you for your feedback. We are considering adding it to our longer term roadmap.

Your help is greatly appreciated,
Business Central Team

Comments

J

This was presented at BcTechDays in September 2022, so it's on the planning board and it's one of the most upvoted Development ideas of AL:

https://youtu.be/LJp0s9jm3KY?t=4978


MS mentions we will be able to run auto-tests through the same development flow as we build/publish/debug.

They also mention "churn-based execution", which would make it possible to use the coverage map to indicate in vscode if the procedures you're looking into are "covered", and by which tests. It would also be able to run a selection of these tests from vscode, and what I envision is we'll have "watch-mode" in AL. Just imagine how many manual steps and time it could save us if we could RAD publish + run affected tests and get instant feedback while coding? This would finally make proper test-driven coding possible.


Constantly switching between the web browser and editor is a bit of an awkward/tedious workflow.

An easier way of writing/running auto-tests encourages maintaining auto-tests (and even makes it fun).

I really hope this starts getting attention/prioritization soon.

Category: Development

J

VS Code recently got new UI for running tests, but AL language extension does not extend that.


Currently the only alternative is AL Test Runner extension (jimmymcp/al-test-runner: VS Code Extension to help run AL tests against Business Central container (github.com)), but it leaves a lot to be desired: it is somewhat buggy, does not support quoted test method names, has poor support for launch configurations (assumes plain JSON, when it is actually JSON with comments), is hard to setup because you get cryptic errors, etc.


Official support for running AL tests from VS Code would really help developers. Currently, I want to recommend test automation, but at the same time I know how tedious and error prone it is just to run the tests (and debug them).


From technical side all we need is an API on BC side that can run test codeunits using development endpoint, and VS Code could use that. This would be much faster than the current VS Code -> PowerShell -> BcContainerHelper\Run-TestsInBcContainer -> some weird API call -> and back all the way. BcContainerHelper could benefit from this too, because just running tests feels incredibly slow - it has to run whole test tool page behind the scenes just to run tests and there is no way to run tests in parallel.


I bet Microsoft too would benefit from better testability tools.

Category: Development

J

We are an end-customer with development license and we need to be able to develop and run Unit-Tests (data-agnostics), but we need to be able to develop Functional-Tests for all our complex business rules with all our real or semi-real setup data in an OnPremise QA environment.

We need TEST that our App runs after every developer change in code, but also after every eventually end-user change in data-setup that could crash our business rules...

Category: Development

J

Totally agree to Ron Koppelaar. I would also vote for the ability to mock functions and codeunits to do better unit-testing. Should it be posted as a separate idea?

Category: Development

J

When looking at improvements in the testing framework, I would vote for ability to truly mock certain functions and codeunits. Like we can do in C#. This gives you to ability to better do unit testing, insteads of full process test.

Category: Development

J

Although I applaud all improvements to Al, then I would just like to say that that ability is already there today. With or without Docker then you can have a very small Powershell script which invokes your test codeunit, or have your test app setup to open the test app in the test toolkit. But you're right we need to be able to do this faster to do TDD, and having to open the client slows us down, so being able to invoke the tests faster without client and still test pages that's important. But what really slows us down is having to publish/unpublish main/test app again and again.

Category: Development