Question
· Feb 25, 2016

Better Unit Testing Strategies for InterSystems Caché Development

Good morning people.
The use of TDD is currently being reference for software delivery more confiabilitade and quality.

At the company I work developing web applications , we create tests for method class in a deteminado package and running the steps that the documentation recommends:

1 export the tests classes to a predefined folder.
2- And running the test ( D ## class (% UnitTest.Manager ) .RunTest (,"/nodelete" )

It is a lot of work to do the export and run these tests would have a resource that we could only run the tests without the need for export ?

Discussion (5)2
Log in or sign up to continue

You may call RunTest with /noload parameter, but you still have to set a valid directory  as a value in ^UnitTestRoot

Set ^UnitTestRoot = "C:\UnitTests"
Do ##class(%UnitTest.Manager).RunTest("mytests:MyPackage.Tests", "/noload/nodelete")

Or so, here you can specify: suit, class and method if you want

Do ##class(%UnitTest.Manager).DebugRunTestCase("mytests","MyPackage.Tests","","")

This call does not load any classes from any directories nor does it delete any classes from Caché. And executes the tests contained in MyPackage.Tests. The optional third argument is for specifying an individual test method within the test class to execute.

Different people are going to have different workflows for unit testing, but I would encourage you to settle on a way to get those tests out of the database. I'd be nervous about running tests in a namespace that contains my only copy, since %UnitTest is designed to load and delete by default.

If you're using Studio with the source control hooks, it works pretty well to write the tests in a development namespace, then run them in a test namespace.

Indeed. Presumably the "load and delete" defaults were a design decision based on the model of running unit tests elsewhere. That seems relevant for a build server, but not so friendly for the developer who you're trying to persuade to code the tests in the first place. Yes, Studio the source control hook facility can be your friend here provided you're prepared to spend enough time getting intimate with it.