【问题标题】:Not Found mysql driver for fixture @Before in Unit test在单元测试中找不到夹具@Before的mysql驱动程序
【发布时间】:2012-06-13 15:00:47
【问题描述】:

伙计们。我有一个奇怪的问题。我尝试为 web-app 编写单元测试。我决定检查一些方法(查询)。这是一个工作应用程序。但是当我使用fixture @Before

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

我在 Class.forName(driver) 中初始化连接池时出错。

有错误 ClassNotFoundException: com.mysql.jdbc.Driver

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

【问题讨论】:

    标签: java junit database-connection fixtures


    【解决方案1】:

    在运行测试时将 MySQL 连接器 JAR 添加到您的 CLASSPATH。

    【讨论】:

    猜你喜欢
    • 2016-07-14
    • 2010-09-06
    • 2010-12-29
    • 2016-04-02
    • 2013-04-22
    • 2019-07-25
    • 2019-04-17
    • 2019-11-07
    • 2010-12-16
    相关资源
    最近更新 更多