2011-02-06 62 views
1

由於某種原因,在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()); 

    } 
+1

錯誤在哪裏? – 2011-02-06 21:37:37

+0

哎呀,那是一場意外。 DELETE javascript標記 – novicePrgrmr 2011-02-06 21:38:17

+0

感謝您的代碼,我能夠明白爲什麼我得到「非法表達式開始」。虛擬我,我試圖使用assert.assertEquals。我刪除了第一個斷言,我停止了這個錯誤。咄! – Patricia 2015-08-25 14:41:07

回答

4

你好像如果馬特是正確的,請不要使用Word編輯程序中使用的替換正常的("

PS「花哨」引號()。有很多IDE,但即使是記事本也會更容易。

3

片段

s]e3.getName1() 

(最後一行)看起來不正確:刪除 「S」 片段。

編輯:您還在代碼末尾丟失了該類的右括號。

相關問題