trial ~13-xunit-reporter

The extensible test runner for DLang


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Build Status Line Coverage DUB Version Percentage of issues still open Average time to resolve an issue

Writing unit tests is easy with Dlang. Unfortunately when you have a big collection of unit tests, it get's hard to maintain and debug them. In order to avoid these problems, you can use this flexible test runner for D programing language.

Motivation

There are many test runners for DLang and there are a few of them that have a lot of useful features that helps you to be more productive. Sometimes you need to use a custom feature that is not embedded with those libraries. Maybe it's about a custom test report, a new discovery mode or an integration with a third party app like an IDE or Jenkins. In each of these cases you need to dig in a project that is not maintained or you need features that does not match the creators view about this subject.

In order to be able to extend your test runs without depending on other people, I propose a simple idea, inspired from well known projects like TestNg, NUnit and mocha, that exposes a simple interface that allows you to add what you want, when you want.

How it works

The trial executable creates a custom main that will be embedded with your code. The build is created using dub embeded as a library, so you don't need to install dub to use this runner. All the parameters that you provide to trial will be passed directly to dub. Right now trial provides only the --test or -t option that will filter the discovered tests. For example trial -t "The user should see a nice message when one test is run" will run only the tests that contain that string in the name.

Features

This library intends to provide a rich set of features that helps you to customize your test runs:

Configurable

The trial command can be configured through the trial.json file. This file will be created when you run trial For the first time. All the root properties are optional. For more details about this file look at the Settings structure.

By default trial will use the unittest configuration. If you need to use test dependencies or other special setup for the test build, you can add a trial configuration inside your package file:

  ...
  "configurations": [ {
      "name": "trial",
      "dependencies": {
        "arsd-official:terminal": "~>1.2.2",
        "fluent-asserts": "~>0.6.0"
      }
    }
  ]
  ...

Read more about dub configurations.

Hacking

Please have a look at trial.interfaces

Building

Clone the repository and run dub build :runner to create the app.

Structure

There are two packages inside this project. The runner packages contains the command line interface to run your tests. lifecycle provides the functionality like test discovery and reporters.

Fluent Asserts

Since DLang does not have a rich assert library, you can use Fluent Asserts, a library that improves your experience of writing tests.

Alternatives

Authors:
  • Szabo Bogdan
Sub packages:
trial:lifecycle, trial:runner
Dependencies:
none
Versions:
0.8.0-beta.5 2023-Jul-15
0.8.0-beta.4 2023-Jun-01
0.8.0-beta.3 2022-Dec-03
0.8.0-beta.2 2022-Jul-26
0.8.0-beta.1 2022-Nov-18
Show all 76 versions
Download Stats:
  • 0 downloads today

  • 6 downloads this week

  • 52 downloads this month

  • 17705 downloads total

Score:
0.9
Short URL:
trial.dub.pm