Danny's profile季节的水滴PhotosBlogListsMore Tools Help

Blog


    9/23/2009

    抱住单元测试不放(转载)

    一般来说,SaaS 的领跑者往往是许多人构建的大型应用程序。大型应用程序的单元测试中,数据总是一致的:在后期执行单元测试的项目总是惨败。与此相反,成功的 SaaS 开发人员在编写代码之前运行单元测试。例如,如果我要编写一个名为ServiceController 的类,我不会直接开始编写该类。相反,我编写根据类中的方法运行所有单元测试用例的类。接下来我甚至会进一步运行测试用例,尽管我知道它们将失败,因为我没有为该类编写任务代码。

    这样做的目的在于,排除单元测试中出现 bug 的可能性,保证总是能通过单元测试。一般来说,很容易无意中犯这个错误。如果所有单元测试都失败,我就可以开始编写实际代码了。当我完成新类的编写时,我将再次运行单元测试。只要通过所有的测试用例,我就将向单元测试自动库添加新的单元测试类,在每次构建时运行。换句话说,我为应用程序创建的整个单元测试库都成为构建流程的一部分。实际上,在我每次开始构建项目之前,都将运行所有的单元测试,以确保应用程序代码的完整性没遭到无意破坏。

    在编程的世界中,我发现只有几个开发人员严格遵守该过程。但是,他们都是行业内最受尊敬的、最具声望、身价最高的开发人员。如果您想知道提高身价的捷径,请坚持单元测试。

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://think4v.spaces.live.com/blog/cns!B7E9CA656247B821!989.trak
    Weblogs that reference this entry
    • None