Skip to content

Persisting Server Data

Tom Longhurst edited this page Nov 5, 2021 · 6 revisions

To persist your data somewhere, you need to create a class that implements the IBDTestDataStore interface.

You can choose anywhere you like for this. For me, I chose Azure Blob Storage.

 

For the IBDTestDataStore interface, you will have 4 methods to implement:

Task StoreTestData(string id, BDTestOutputModel data);
  • This is to store the data for a test result, and it should be stored using the given ID, as this is what we will use to retrieve it later.
Task<BDTestOutputModel> GetTestData(string id);
  • This is to retrieve the test result data with the given ID.
Task StoreTestRunRecord(TestRunSummary testRunSummary);
  • This is to store a 'summary' of a test run. This is used to populate the Test Runs list. It's just a small piece of data, giving an overview of things like tests passed/failed, date+time, and any tags you've associated with that test run. This should be stored using the "RecordId" property: testRunSummary.RecordId
Task<TestRunSummary[]> GetAllTestRunRecords();
  • This is to get all of the test run summaries to display on the Test Runs list. E.g. if using SQL, you could do something like select all where datetime within last 30 days (pseudo-query)

   

For me, I created an AzureStorageDataStore (See the bottom of this post for the implementation.) Once you have your implementation, you need to register it under the DataStore property of the options when calling UseBDTestReportServer:

            app
                .UseBDTestReportServer(options =>
                {
                    options.DataStore = new AzureStorageDataStore();
                });

That's it! You should have a report server with a persistent data store now.

Clone this wiki locally