不知道为什么我得到一个非法的字符错误
问题描述:
由于某种原因,在testEmployee方法中,我收到奇怪的错误消息说非法字符。不知道为什么我得到一个非法的字符错误
我看过代码,但找不到任何语法错误。
任何帮助将非常感谢!
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import ttp.Cache;
import ttp.DataException;
import ttp.EmployeeDAO;
import ttp.Employee;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author ericrea
*/
public class Tester {
public Tester() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
// @Test
// public void hello() {}
// /** Test the Skeleton BO/DAO */
// @Test
// public void TestSkeleton() throws Exception {
// Skeleton s = SkeletonDAO.getInstance().create(“skeleton1”);
// s.save();
//
// // since skeleton1 is in the Cache, this tests reading from the cache
// Skeleton s2 = SkeletonDAO.getInstance().read(“skeleton1”);
// assertSame(s, s2);
//
// // now clear the cache (you’d never do this in the real world)
// // then we can test reading from the database
// Cache.getInstance().clear();
// Skeleton s3 = SkeletonDAO.getInstance().read(“skeleton1”);
// assertEquals(s.getId(), s3.getId());
// //assertEquals(s.getSomething(), s3.getSomething());
//
// // keep testing more methods, BOs, and DAOs
// }//TestSkeleton
// //5. Right-click the file and run the file. You’ll see it test. It will obviously have errors
// //because Skeleton isn’t a real BO/DAO.
// //6. Note in the above code the “assertEquals” methods. That is how you test that two things are equals.
@Test
public void TestEmployee() throws DataException {
Employee e = EmployeeDAO.getInstance().create(“Employee1”);
e.save();
// since skeleton1 is in the Cache, this tests reading from the cache
Employee e2 = EmployeeDAO.getInstance().read(“Employee1”);
assertSame(e, e2);
// now clear the cache (you’d never do this in the real world)
// then we can test reading from the database
Cache.getInstance().clear();
Employee e3 = EmployeeDAO.getInstance().read(“Employee1”);
assertEquals(e.getId(), e3.getId());
assertEquals(e.getName1(), s]e3.getName1());
}
答
你好像如果马特是正确的,请不要使用Word编辑程序中使用的替换正常的("
)
PS“花哨”引号(“
)。有很多IDE,但即使是记事本也会更容易。
答
片段
s]e3.getName1()
(最后一行)看起来不正确:删除 “S” 片段。
编辑:您还在代码末尾丢失了该类的右括号。
错误在哪里? – 2011-02-06 21:37:37
哎呀,那是一场意外。 DELETE javascript标记 – novicePrgrmr 2011-02-06 21:38:17
感谢您的代码,我能够明白为什么我得到“非法表达式开始”。虚拟我,我试图使用assert.assertEquals。我删除了第一个断言,我停止了这个错误。咄! – Patricia 2015-08-25 14:41:07