Unit testing is one of the most essential processes of application development in which we test a particular part of the code of the application to see if it's working correctly or not.
In the D language, we use a built-in function called unittest
to test whether a particular part of the code is working correctly or not.
unittest{//code you want to test}
unittest
and pass the test case within the curly bracket we want to test.class multiply{int mul(int x, int y) { return x * y; }// Call the build in unittest functionunittest{ // Define the test casemultiply m = new multiply;assert(m.mul(3,12) == 36);}}void main() {}
unittest
function and provide the test case within the curly bracket. 1 modules passed unittests
. But if the test passes the wrong result, it shows modules FAILED unittests
in the output.Free Resources