shunit2单元测试框架

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Hearbeat/article/details/80531189
shUnit2 是基于伯恩的 shell 脚本,xUnit 单元测试框架,它旨在 JUnit、 PyUnit 等以类似的方式工作。如果你有过写一个 shell 脚本的单元测试的愿望,shUnit2 不能通过测试的 job.has。

下载地址:
https://code.google.com/p/shunit2/
帮助:
https://code.google.com/p/shunit2/wiki/GeneralFaq

使用方式:http://wenku.baidu.com/view/4096d90eba1aa8114431d943.html
#!/bin/sh
hello()
{
    echo "hello,word!";
}
test_hello()
{
    assertEquals "$(hello)" 'hello,word!'
}
. /usr/share/shunit2/shunit2

输出:


shunit2单元测试框架
assertEquals三个参数时:

assertEquals "${msg}" "${expected}" "${actual}"


猜你喜欢

转载自blog.csdn.net/Hearbeat/article/details/80531189