Regression test with database accessSeptember 11, 2017 7:57 pm Leave your thoughts
Testing has always been a hot topic between developers, product owners, and customers. When should we start to test, what should we test, why is it needed and how should it be done, are some common questions that often need to be answered before the first tests are implemented. Regardless of what the answers may be, a developer needs tools to implement these tests, execute them and integrate them into the Continuous Integration chain.
Running system tests for a Starcounter application in regression may be done through the Selenium test framework while unit testing can be done through Xunit. But what if the tested code in a unit test contains a database query or transaction, then the executed test needs to be connected to the Starcounter database. Until the functionality is released to connect to a database host programmatically i.e.
Self-hosting apps, the actual test application needs to be a Starcounter application which is deployed to the database and then executed. The
Starcounter.Xunit.Runner library has been developed to bridge this gap.
So what is Starcounter.Xunit.Runner?
It is a runner for executing Xunit tests directly from the code. The library is available as a NuGet package which includes the Xunit framework. From version
1.2.0, it also includes the functionality to generate Xunit standard XML and HTML output files, exactly as the xunit.console.runner does. This means that it is easily integrated into any CI platform that has Xunit plugins.
In order to execute the tests, simply place this the code snippet below either in
Main() method, to execute the tests on deploy or in a
Handle.GET() request, to execute them on demand. It will execute all tests found within the calling assembly.
StarcounterXunitRunner runner = new StarcounterXunitRunner(); runner.Start();
Please visit the source code on GitHub to see the full API documentation and a demo of how to fully use this library.
Starcounter.Xunit.Runner was developed with the functionality in mind to play nicely with CI servers and to be easily switched into using native Xunit runners when
Self-hosting apps has been released. So whatever reason you might have to implement tests, there are at least proper tools to do so now.
Categorised in: Uncategorized
This post was written by Urban Nydén