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>