---
title: "D语言unit test"
author: "yaasshole"
date: "2012-02-26T12:09:00Z"
tags: []
slug: "d-unit-test"
draft: false
lastmod: "2012-02-28T08:57:20Z"
id: 1428329
url: "https://yaasshole.iteye.com/blog/1428329"
---

参考文档[http://dlang.org/unittest.html](http://dlang.org/unittest.html)

但是要注意几点，至少需要提供一个main函数

编译时用-unittest参数

运行时只有测试失败才会输出一堆信息。

不过这些信息显然和输出测试报告相距甚远。

比如我的main.d文件：

sum.d

编译命令：

dmd -unittest main.d sum.d

运行 ./main

结果如下：