travis CI如何创建DB?

时间:2015-12-31 10:40:52

标签: mysql junit travis-ci

.travis.yml文件

language: java
sudo: required

jdk:
  - oraclejdk8

test:
  adapter: mysql2
  database: historyboard
  username: root
  encoding: utf8

before_script:
  - echo "USE mysql;\nUPDATE user SET password=PASSWORD('test') WHERE user='root';\nFLUSH PRIVILEGES;\n" | mysql -u root
  - mysql -e 'create database IF NOT EXISTS BOARD_DB;'
  - mysql -e "use BOARD_DB;"


  - mysql -e "USE mysql;
    DROP TABLE IF EXISTS board;

    CREATE TABLE board (
      b_index int(10) NOT NULL AUTO_INCREMENT,
      email varchar(80) DEFAULT NULL,
      password varchar(40) DEFAULT NULL,
      w_date datetime DEFAULT NULL,
      updated_at datetime DEFAULT NULL,
      content text,
    PRIMARY KEY (b_index)
    ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;"

我在travis.yml文件中添加了创建数据库脚本

但是在travis CI构建中,Junit Test无法加载表BOARD_DB.board

如何在Travis CI中为JUnit TestCase添加MySQL DB和表?

TEST错误日志

### SQL: INSERT INTO board         (             email,              password,              w_date,              content         )         VALUES         (             ?,              ?,              now(),              ?         )
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'BOARD_DB.board' doesn't exist

如何修复此Travis CI构建错误?

0 个答案:

没有答案