単体テストを行うとすると、メソッドのentryのところでvoidによるエラーが出てしまうのですが、どうすれば解決できますか?
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import org..tcm.bean.CustomerBean;
import org.sasami.tcm.common.DataBaseAccess;
public class CustomerEntry {
public void entry(CustomerBean customerBean) throws Exception { DataBaseAccess EntryAccess = new DataBaseAccess(); try { EntryAccess.open(); Class.forName("org.postgresql.Driver"); Connection con = DriverManager.getConnection( "jdbc:postgresql://); String SQL = "INSERT INTO TB_CUSTOMER(ID,PASSWORD," + "ADDRESS,TEL) " + " VALUES(?, ?, ?, ?) "; EntryAccess.setSql(SQL); PreparedStatement preparedStatement = con.prepareStatement(SQL); preparedStatement.executeUpdate(SQL); EntryAccess.setMultiType(1, customerBean.getId()); EntryAccess.setMultiType(2, customerBean.getPassword()); EntryAccess.setMultiType(3, customerBean.getAddress()); EntryAccess.setMultiType(4, customerBean.getTel()); } catch (Exception e) { e.printStackTrace(); }finally{ try { if (EntryAccess != null) { EntryAccess.close(); } } catch (SQLException e) { e.printStackTrace(); } } }
}
単体テスト
import org.junit.Test;
import org.sasami.tcm.bean.CustomerBean;
import junit.framework.TestCase;
public class CustomerEntryTest extends TestCase{
public CustomerEntryTest(String[] args) { } @Test public void testEntry() { CustomerEntry customerentry = new CustomerEntry(); CustomerEntry number = customerentry entry() }
}
あなたの回答
tips
プレビュー