1.測試環境java
Junitandroid
2.測試說明程序員
單元測試(最微小規模的測試;以測試某個功能或代碼塊。典型地由程序員而非測試員來作,由於它須要知道內部程序設計和編碼的細節知識。這個工做不容易作好,除非應用系統有一個設計很好的體系結構; 還可能須要開發測試驅動器模塊或測試套具。)app
3.測試方法框架
importjava.util.Scanner;單元測試
importjavax.script.ScriptEngine;測試
importjavax.script.ScriptEngineManager;ui
importjavax.script.ScriptException;this
importorg.junit.Before;編碼
importorg.junit.Test;
public class carteenmanagesystem {
@Before
publicvoidsetUp() throws Exception {
}
@Test
publicvoidtest() {
//fail("Not yet implemented");
ScriptEngineManagersem = newScriptEngineManager();
ScriptEnginese = sem.getEngineByName("js");
Scanner sc = newScanner(System.in);
while(true)
{
System.out.print("輸入你的對餐廳服務的意見");
String line = sc.nextLine().trim();
try
{
Object result = se.eval(line);
System.out.println(line);
}
catch(ScriptExceptione)
{
System.out.print("意見不能爲空");
sc.close();
break;
}
}
}
}
stampToDate
方法,測試時我認爲應該返回的結果等於最終的結果是否相同。
dateToStamp
方法。
dateToStamp
方法中,有拋出一個解析異常(ParseException)。也就是當參數沒有按照規定格式去傳,就會致使這個異常。
@Test
註解設置
expected
參數來實現
build.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Android auto-generated file.
Any modifications will be overwritten.
To include a user specific buildfile here, simply create one in the same
directory with the processing instruction <?android.ant.import?>
as the first entry and export the buildfile again. --><project basedir="." default="build" name="testone">
<property environment="env"/>
<propertyname="ANDROID_HOME" value="../../android/"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.8"/>
<property name="source" value="1.8"/>
<path id="testone.classpath">
<pathelement location="bin"/>
</path>
<target name="init">
<mkdirdir="bin"/>
<copy includeemptydirs="false" todir="bin">
<filesetdir="src">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="bin"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="build-subprojects,build-project" name="build"/>
<target name="build-subprojects"/>
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
<src path="src"/>
<classpathrefid="testone.classpath"/>
</javac>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target description="copy Android compiler jars to ant lib directory" name="init-android-compiler">
<copy todir="${ant.library.dir}">
<filesetdir="${ANDROID_HOME}/plugins" includes="org.android.jdt.core_*.jar"/>
</copy>
<unzip dest="${ant.library.dir}">
<patternset includes="jdtCompilerAdapter.jar"/>
<filesetdir="${ECLIPSE_HOME}/plugins" includes="org.android.jdt.core_*.jar"/>
</unzip>
</target>
<target description="compile project with Android compiler" name="build-android-compiler">
<property name="build.compiler" value="org.android.jdt.core.JDTCompilerAdapter"/>
<antcall target="build"/>
</target>
<target name="carteenmanagesystem">
<java classname="teston.carteenmanagesystem" failonerror="true" fork="yes">
<classpathrefid="testone.classpath"/>
</java>
</target>
</project>