技术宅,fat-man

增加语言的了解程度可以避免写出愚蠢的代码

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

可以将测试结果作为邮件发送出去的NANT脚本

复制代码
<?xml version="1.0"?>
<project name="WebApp" default="run_test" basedir=".">
    
    <!--编译方式-->
    <property name="DEBUG" value="true" />
    <!--目录与文件配置-->
    <property name="SRC" value="./trunk" />    
    <property name="BIN" value="./trunk/bin" />
    <property name="SQL_SCRIPT" value="./trunk/script/db.sql" />
    <!--SVN 地址和帐号信息-->
    <property name="SVN_SERVER" value="http://127.0.0.1:8080/svn/WebApp/trunk" />
    <property name="SVN_USERNAME" value="lishujun" />
    <property name="SVN_PASSWORD" value="aaa" />
    <!--数据库信息-->
    <property name="SQL_SERVER" value="(local)" />
    <property name="SQL_USERNAME" value="sa" />
    <property name="SQL_PASSWORD" value="123456" />
    
    <!--删除源码和可执行程序-->
    <target name="clean">
        <delete dir="${SRC}" />
    </target>

    <!--重新获取源码,重建SQL数据库-->
    <target name="checkout" depends="clean">
        <exec program="svn" commandline="export ${SVN_SERVER} --username ${SVN_USERNAME} --password ${SVN_PASSWORD}" />
        <exec program="sqlcmd" commandline="-S ${SQL_SERVER} -U ${SQL_USERNAME} -P ${SQL_PASSWORD} -i ${SQL_SCRIPT}" />
    </target>
    
    <!--编译程序-->
    <target name="build_dal" depends="checkout">
        <csc target="library" output="${BIN}/DAL.dll" debug="${DEBUG}">
            <sources  basedir="${SRC}/DAL">
                <include name="*.cs"/>
            </sources>
        </csc>
    </target>

    <target name="build_bll" depends="build_dal">
        <csc target="library" output="${BIN}/BLL.dll" debug="${DEBUG}">
            <sources basedir="${SRC}/BLL">
                <include name="*.cs"/>
            </sources>

            <references basedir="${BIN}/">
                <include name="DAL.dll" />
            </references>
        </csc>    
    </target>

    <target name="build" depends="build_bll">
        <csc target="library" output="${BIN}/UnitTest.dll" debug="${DEBUG}">
            <sources basedir="${SRC}/UnitTest">
                <include name="*.cs"/>
            </sources>

            <references basedir="${BIN}/">
                <include name="BLL.dll" />
                <include name="${nant::scan-probing-paths('nunit.framework.dll')}" />
            </references>
        </csc>
    </target>
    
    <!--运行测试-->
    <target name="run_test" depends="build">
        <nunit2>
            <formatter type="Xml" usefile="true" extension=".xml" outputdir="${BIN}" />
            <test>
                <assemblies basedir="${BIN}">
                    <include name="UnitTest.dll" />
                </assemblies>
                <references basedir="Libraries">
                    <include name="BLL.dll" />
                </references>
            </test>
        </nunit2>
    </target>
    
    <!--将测试结果(XML文件)作为正文发送给需要阅读的人-->
    <target name="send_result">
        <mail
            from="icoding@qq.com" 
            tolist="58135482@qq.com" 
            user="icoding@qq.com" 
            password="******" 
            subject="持续集成测试报告" 
            mailhost="smtp.qq.com">
            <files>
                <include name="${BIN}/UnitTest.dll-results.xml"/>
            </files>
        </mail>
    </target>
</project>
复制代码

 

posted on   codestyle  阅读(307)  评论(0编辑  收藏  举报

编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述
点击右上角即可分享
微信分享提示