可以将测试结果作为邮件发送出去的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="[email protected]" 

            tolist="[email protected]" 

            user="[email protected]" 

            password="******" 

            subject="持续集成测试报告" 

            mailhost="smtp.qq.com">

            <files>

                <include name="${BIN}/UnitTest.dll-results.xml"/>

            </files>

        </mail>

    </target>

</project>

 

你可能感兴趣的:(邮件发送)