Converts C# XUnit tests to NUnit tests.
Disclaimer: Far from perfect - something I used as a quick hack to convert loads of large tests
npm install xunit-to-nunit
var x2n =
Convert test from string
var nunitTest = x2n
Convert test from file
Convert tests from directory
This function calls
convertFile for all files in the source directory.
convertFiles has a third (optional) parameter:
options. This should be a dictionary value, containing all or any of the following parameters:
🔧 recursive (default:
true, this parameter will convert tests in all subdirectories including those at the source root. Directory structure is maintained at the conversion destination.
🔧 verbose (default:
true, the module logs an info message to the terminal when a file is converted. When a file conversion fails, a error log message is displayed regardless of the value of
var options =recursive: trueverbose: falsex2n
Writing converted tests to source directory
When source = destination, '
_NUnit' is appended to the filename. For example, where destination =
dir/SomeTests.cs is converted and the result is written to
This behaviour can be changed with the following parameters:
🔧 append (default:
String to be appended to filenames when writing destination files to the source directory.
🔧 overwrite (default:
overwrite = true,
append is ignored, and source files are overwritten at destination.
// Append destination filenames with `append` textvar options =append: '_Test'overwrite: false // `overwrite` is false by default// or, overwrite source filesvar options =overwrite: truex2n
Feel free to add things / suggest things to be added by either opening an issue or by submitting a pull request.