2012-06-13 24 views
0

guys。我有一個奇怪的問題。我嘗試將單元測試寫入web應用程序。我決定檢查一些方法(查詢)。這是一個有用的應用程序。但是,當我使用夾具@Before未找到夾具的mysql驅動程序@Before在單元測試中

@Before 
    public void setUp() throws ConnectionException { 
     Connection connection = null;  
     ConnectionPool.init();    
     connection = ConnectionPool.getInstance().takeConnection(); 
} 

我有錯誤,當我初始化連接池在Class.forName(驅動程序)。

有了錯誤 ClassNotFoundException的:com.mysql.jdbc.Driver

我不知道。也許有人知道原因。

回答

1

運行測試時,將MySQL連接器JAR添加到您的CLASSPATH中。

+0

我該怎麼做(Netbeans 7.1 Ubuntu)? – Ray

+0

如果您不知道CLASSPATH,請勿使用IDE:http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/classpath.html – duffymo