-
Notifications
You must be signed in to change notification settings - Fork 2
Configuration
In order to start using of StoryLine.Rest the following configuration actions must be performed:
- Register all services which expected to be used during test development
- Register assemblies which needs to be scanned to find embedded resources used to validate response results.
In order to register endpoint the following lines needs to be added:
StoryLine.Rest.Config.AddServiceEndpont("Membership", "http://base1.address");
StoryLine.Rest.Config.AddServiceEndpont("Porfolio", "http://base2.address");
This registration must happen once for test execution session. The following restrictions must be taken into consideration:
- Service names must be unique.
- Base address must be valid absolute path.
Once service registered it can be used by HttpRequest action as follows:
.Performs<HttpRequest>(x => x.Service("CRM"))
NOTE: If tests register only one service base address there is no need to refer to this endpoint in each test case. StoryLine.Rest will use registered endpoint by default. Of more then one endpoint is registered and service name is not provided then configuration exception will be thrown.
Some expectations may use embedded resources as expected results. In order to support this feature resource assemblies must be registered using the following lines of code:
StoryLine.Rest.Config.SetAssemblies(typeof(Config).GetTypeInfo().Assembly);
It's possible to specify more than one assembly. Usually it's not practical to store resources in assembly other than assembly containing tests.
In many cases it's beneficial to know what API endpoints have good test coverage and which doesn't have any test. In order to get this information StoryLine.Rest.Coverage tool can be used. One of parameters used by tool is test execution log. This log can be configured by adding lines below.
// Test initializer for XUnit test framework
public class Config : IDisposable
{
private readonly ResponseLogger _responseLogger = new ResponseLogger($"responses-{DateTime.Now:yyyy-MM-dd}.txt");
// This block is run before any test of project is executed
public Config()
{
StoryLine.Rest.Config.AddResponseLogger(_responseLogger);
}
// This block is executed after all tests of test project are executed
public void Dispose()
{
_responseLogger.Dispose();
}
}
NOTE: Code above must be executed once before and after execution of test package. .