[JAVA] [For beginners] I tried using DBUnit in Eclipse

__ * All information is as of the time the article was created .__

What is DBUnit

--A framework for unit testing programs that access DB [1] --Positioned as "extension of JUnit" [1]

Operating environment

Hardware: MacBook Pro (Retina, 13-inch, Mid 2014) OS: MacOS Mojave 10.14.3 IDE: Eclipse 2019-03 (Japaneseized) DBMS: MySQL 8.0.16 JUnit: JUnit5

Make DBUnit work in Eclipse

Things necessary

Download DBUnit

  1. Access the following site
    https://search.maven.org/search?q=g:org.dbunit

  2. Click the download icon

  3. Click "jar" <img width = "1150" alt = "Screenshot 2019-06-16 17.14.35.png " src = "https://qiita-image-store.s3.ap-northeast-1" .amazonaws.com/0/210617/2d3e2f09-2361-c72d-925b-f1287de0d537.png ">

  4. dbunit-2.6.0.jar will be downloaded, so move to any directory

  5. Start Eclipse

  6. In "Project Explorer", right-click the project that uses DBUnit.

  7. Click "Properties".

  8. Select "Java Build Path" and click "Library".

  9. Click "Add External JAR". <img width = "768" alt = "Screenshot 2019-06-16 17.18.38.png " src = "https://qiita-image-store.s3.ap" -northeast-1.amazonaws.com/0/210617/56e44814-2ef6-bbf1-c8ef-f8839ba485e5.png ">

  10. Select the dbunit-2.6.0.jar placed in 4. and click" Open ". <img width =" 372 "alt =" Screenshot 2019-06-16 17.19.32.png "src = "https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/210617/dd2a6a5f-bca4-bec2-44c9-dbe8060966bf.png ">

  11. Click "Apply and Close"

Download SLF4J

  1. Access the following site
    https://www.slf4j.org/download.html

  2. Click "slf4j-1.7.26.zip" <img width = "1127" alt = "Screenshot 2019-06-16 17.26.47.png " src = "https://qiita-image-store.s3" .ap-northeast-1.amazonaws.com/0/210617/4bda7e0c-9c0f-aca1-878f-16bcb08e36a1.png ">

  3. slf4j-1.7.26.zip will be downloaded, so unzip it.

  4. Move slf4j-1.7.26 / slf4j-api-1.7.26.jar and
    slf4j-1.7.26 / slf4j-nop-1.7.26.jar to any directory

  5. Start Eclipse

  6. In "Project Explorer", right-click the project that uses DBUnit.

  7. Click "Properties".

  8. Select "Java Build Path" and click "Library".

  9. Click "Add External JAR". <img width = "768" alt = "Screenshot 2019-06-16 17.18.38.png " src = "https://qiita-image-store.s3.ap" -northeast-1.amazonaws.com/0/210617/58a6bb06-9d6a-3194-ad12-4293fb5b1b39.png ">

  10. Select slf4j-api-1.7.26.jar and slf4j-nop-1.7.26.jar placed in 4. and click "Open". <img width = "425" alt = " Screenshot 2019-06-16 17.20.07.png "src =" https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/210617/916ace08-a268-83ed-07ed- f6d44b383b9c.png ">

  11. Click "Apply and Close"

Download Apache POI

  1. Access the following site.
    http://poi.apache.org/download.html

  2. Click "poi-bin-4.1.0-20190412.zip" in "Binary Distribution". <img width = "1267" alt = "Screenshot 2019-06-17 18.57.00.png " src = "https" //qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/210617/8374a066-a845-8f86-d171-699aa31a6693.png ">

  3. poi-bin-4.1.0-20190412.zip will be downloaded, so unzip it.

  4. Move the unzipped folder poi-bin-4.1.0 to any directory.

  5. Start Eclipse.

  6. In "Project Explorer", right-click the project that uses DBUnit.

  7. Click "Properties".

  8. Select "Java Build Path" and click "Library".

  9. Click "Add External JAR". <img width = "768" alt = "Screenshot 2019-06-16 17.18.38.png " src = "https://qiita-image-store.s3.ap" -northeast-1.amazonaws.com/0/210617/58a6bb06-9d6a-3194-ad12-4293fb5b1b39.png ">

  10. Select the following 4 jar files and click "Open".
    poi-4.1.0.jar
    poi-ooxml-4.1.0.jar
    poi -ooxml-schemas-4.1.0.jar
    ʻooxml-lib / xmlbeans-3.1.0.jar` Screenshot 2019-06-17 18.54.39.png

  11. Click "Apply and Close".

next

Create a DAO class and test it (article creation)

reference

[1] [Think IT] Part 1: What is Java unit test tool DBUnit? (1/3)

Recommended Posts

[For beginners] I tried using DBUnit in Eclipse
[For beginners] I tried using JUnit 5 in Eclipse
I tried using an extended for statement in Java
I tried using Spring + Mybatis + DbUnit
I tried using JWT in Java
I tried using Elasticsearch API in Java
[For beginners] How to debug in Eclipse
I tried setting Java beginners to use shortcut keys in eclipse
I tried using Docker for the first time
I tried using Gson
Prepare for log output using log4j in Eclipse.
I tried using TestNG
I tried using Galasa
I tried using a database connection in Android development
I tried using Google Cloud Vision API in Java
I tried using the Migration Toolkit for Application Binaries
I tried using Docker Desktop for Windows on Windows 10 Home
I tried using azure cloud-init
[For super beginners] DBUnit super introduction
I tried using Apache Wicket
I tried using Java REPL
Using Amateurs UML in Eclipse
I tried metaprogramming in Java
I tried to introduce Bootstrap 4 to the Rails 6 app [for beginners]
[Rails] I tried using the button_to method for the first time
I tried using Dapr in Java to facilitate microservice development
I tried using anakia + Jing now
Rock-paper-scissors game for beginners in Java
[For beginners] Run Selenium in Java
I tried using JOOQ with Gradle
I tried putting Domino11 in CentOS7
I tried using Java8 Stream API
[Android] I tried using Coordinator Layout.
I tried using Pari gp container
I tried using WebAssembly Stadio (2018/4/17 version)
I tried using Java memo LocalDate
I tried using GoogleHttpClient of Java
I tried to display the calendar on the Eclipse console using Java.
I tried a calendar problem in Ruby
I tried using Realm with Swift UI
I tried using Java's diagnostic tool Arthas
I tried using UICollectionViewListCell added from Xcode12.
I searched for CSRF in Ruby's Gem
I tried Cassandra's Object Mapper for Java
I tried using Scalar DL with Docker
I tried the new era in Java
I got stuck using snake case for variable name in Spring Boot
Enable code completion in Eclipse for Mac
I tried using OnlineConverter with SpringBoot + JODConverter
It's new, but I tried using Groonga
I tried using OpenCV with Java + Tomcat
I wrote EX25 of AtCoder Programming Guide for beginners (APG4b) in java.
I tried the AutoValue library in Intellij
I tried to make a talk application in Java using AI "A3RT"
I tried embedding a formula in Javadoc
I tried using Junit on Mac VScode Maven
I tried barcode scanning using Rails + React + QuaggaJS
Eclipse Pleiades All in One for Mac released
I tried to implement polymorphic related in Nogizaka.
ChatWork4j for using the ChatWork API in Java
Technology for reading Java source code in Eclipse