ユニット・テストの概要

Similar documents
新・明解Java入門

Gartner Day

Oracle9i JDeveloperによるWebサービスの構築

untitled

PowerPoint Presentation

Exam : 1z1-809-JPN Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z1-809-JPN Exam's Question and Answers 1 from Ac

ALG ppt

untitled

Java演習(4) -- 変数と型 --

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

Microsoft PowerPoint ppt


やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

XMLテクノロジを使いやすくする

tkk0408nari


解きながら学ぶJava入門編

Oracle Application Server 10g Release 3(10.1.3)- アジャイル・エンタープライズ(俊敏な企業)のためのデータ・アクセス

ValueHolder... 9 Customer.java Oracle TopLink 10g(10.1.3) È Volume3 2

Oracle Identity Managementの概要およびアーキテクチャ

Oracle Forms Services R6i

TopLink å SampleClient.java... 5 Ò readallsample() querysample() cachesample() Ç..

Microsoft Word - migrateto10g2.doc

K227 Java 2

3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World");

組織変更ライブラリ

PowerPoint プレゼンテーション

. IDE JIVE[1][] Eclipse Java ( 1) Java Platform Debugger Architecture [5] 3. Eclipse GUI JIVE 3.1 Eclipse ( ) 1 JIVE Java [3] IDE c 016 Information Pr

Oracle9i JDeveloper R9.0.3 チュートリアル

9iAS_DEV.PDF

Oracle JDeveloper 10g ADF Creation Date: Jul 07, 2004 Last Update: Jul 08, 2004 Version 1.0

ワークショップ テスト駆動開発

(Eclipse\202\305\212w\202\324Java2\215\374.pdf)

226

Javaセキュアコーディングセミナー東京 第3回 入出力(File, Stream)と例外時の動作 演習解説

Q&A集

WebOTXマニュアル

Java (5) 1 Lesson 3: x 2 +4x +5 f(x) =x 2 +4x +5 x f(10) x Java , 3.0,..., 10.0, 1.0, 2.0,... flow rate (m**3/s) "flow

r1.dvi

TopLink È... 3 TopLink...5 TopLink åø... 6 TopLink å Workbench O/R ~... 8 Workbench À ~... 8 Foundation Library å... 8 TopL

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1

untitled

VB.NETコーディング標準

Oracle Locator Oracle Database 10g Standard Edition Standard Edition One Oracle Database 10g Release 1 Oracle Locator : Enterprise Edition Oracle Loca

Condition DAQ condition condition 2 3 XML key value

intra-mart Accel Platform — イベントナビゲータ 開発ガイド   初版   None

Oracle Application Server10g (9.0.4) - OracleAS PortalによるOracleAS Web Cacheの配置

intra-mart Accel Platform — イベントナビゲータ 開発ガイド   初版  

JAVA とテンプレート

Microsoft Word - 430_15_Developing_Stored_Procedure.doc

Java プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲

1 Java Java GUI , 2 2 jlabel1 jlabel2 jlabel3 jtextfield1 jtextfield2 jtextfield3 jbutton1 jtextfield1 jtextfield2 jtextfield3

二分木ヒープとは 集合 リストから 最小な 要素を取り出す 二分木ヒープは そのための標準的データ構造 二分木ヒープを保存するデータ構造 二分木ヒープの操作のメソッド 対象となるデータクラス 識別のためのlabelフィールド 値を保持するvalueフィールド

ALG ppt

Oracle Application Server 10g (9.0.4): Manually Managed Cluster

Quick Sort 計算機アルゴリズム特論 :2017 年度 只木進一

ERP連携モジュールチュートリアル

Oracle Real Application Clusters 10g Release 2: Microsoft SQL Server 2005との技術的比較

日本語タイトルを入力

Oracle Database 10gのOLAP Option

I java A

アルゴリズムとデータ構造1

データ構造とアルゴリズム論

JUnit 概要 2015/4/16 版今泉俊幸 2015 bbreak Systems 1

オブジェクト脳のつくり方

目的 泡立ち法を例に Comparableインターフェイスの実装 抽象クラスの利用 型パラメタの利用 比較 入替 の回数を計測

Microsoft Word - J-jdev_dba_db_developers.doc

5 p Point int Java p Point Point p; p = new Point(); Point instance, p Point int 2 Point Point p = new Point(); p.x = 1; p.y = 2;

Java学習教材

Oracle HTML DBのテンプレート・カスタマイズ

インターネットマガジン2001年4月号―INTERNET magazine No.75

JavaプログラミングⅠ

JAVA H13 OISA JAVA 1

BC4J...4 BC4J Association JSP BC4J JSP OC4J


ALG ppt

GIMP import javafx.application.application; import javafx.scene.scene; import javafx.scene.canvas.canvas; import javafx.scene.canvas.graphicscontext;

CAC

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

Oracle Lite Tutorial

r02.dvi

ohp02.dvi

Oracle Secure Enterprise Search 10gを使用したセキュアな検索

問題1 以下に示すプログラムは、次の処理をするプログラムである

AJAXを使用した高い対話性を誇るポートレットの構築

1: Preference Display 1 package sample. pref ; 2 3 import android. app. Activity ; 4 import android. content. Intent ; 5 import android. content. Shar

Microsoft Word - J-migratingjdevelope#110A7A.doc

Warehouse Builderにおける予測分析の使用

Thread

Javaセキュアコーディングセミナー2013東京第1回 演習の解説

文字列操作と正規表現

3 p.1 3 Java Java Java try catch C Java if for while C 3.1 boolean Java if C if ( ) 1 if ( ) 1 else , 2 { } boolean true false 2 boolean Gr

: : : TSTank 2

(Microsoft PowerPoint - \223\306\217KJAVA\221\346\202R\224\ ppt)

java_servlet2_見本

presen.gby

JAVA 11.4 PrintWriter 11.5

NPCA部誌2018

今回の内容 グラフとオブジェクト指向プログラミング Java を使う理由 Java の基本 Javaのライブラリ 開発 実行 クラスの再利用 クラス継承 抽象クラス 開発の要点

問 次の Fortran プログラムの説明及びプログラムを読んで、設問に答えよ。

Transcription:

2004 12

... 3... 3... 4... 5... 6... 6 JUnit... 6... 7 Apache Cactus... 7 HttpUnit/ServletUnit... 8 utplsql... 8 Clover... 8 Anthill Pro... 9... 10... 10... 10 SQL... 10 Java... 11... 11... 12... 12 setter getter... 12 CRUD... 12... 12... 13... 13... 13... 14 : StringUtils... 14 : Person... 16 : StringUtilsTester... 18 : PersonTester... 20... 21... 22 ADF... 23 ADF... 23 ADF CRUD... 25 2 Oracle Corporation Getting Started With Unit-testing

Java 1 1 3 Oracle Corporation Getting Started With Unit-testing

3 substitute() public static void testsubstitute() assertequals("a bear", StringUtils.substitute("a goose", "goose", "bear")); substitute() public static String substitute (String text, String replace, String with) return new String("a donkey"); a bear a donkey 1 public static String substitute (String text, String replace, String with) return new String("a bear"); substitute() substitute() text replace with NULL 4 Oracle Corporation Getting Started With Unit-testing

IDE 3 1 2 3 assertequals() substitute ("a goose", "goose", "bear") a bear 5 Oracle Corporation Getting Started With Unit-testing

2 1 1 1 JUnit Java JUnit OTN JUnit Extension JDeveloper JUnit JUnit 6 Oracle Corporation Getting Started With Unit-testing

[JDeveloper home]\jdev\lib\ext Oracle JDeveloper 10.1.2 http://www.junit.org JUnit JVM Java JUnit JDeveloper JUnit HTTP EJB JVM http://www.mockobjects.com Apache Cactus Apache Cactus Cactus JUnit OC4J Tomcat Cactus EJB JSP XSLT Cactus http://jakarta.apache.org/cactus/ 7 Oracle Corporation Getting Started With Unit-testing

Cactus Web Cactus HttpUnit HttpUnit/ServletUnit HttpUnit Web HTTP HttpUnit JavaScript Cookie Web HttpUnit ServletUnit JUnit Cactus HttpUnit ServletUnit http://httpunit.sourceforge.net/ HttpUnit UI HttpUnit utplsql Oracle PL/SQL PL/SQL http://utplsql.sourceforge.net/ utplsql Clover 1 Clover Jakarta Ant Clover Clover Clover JDeveloper 10g Clover http://www.thecortex.net/clover/ Clover 8 Oracle Corporation Getting Started With Unit-testing

Clover レポートの例 JDeveloper に統合できる Clover Anthill Pro Anthill Pro は ソフトウェア ビルド管理サーバーです Anthill Pro により Apache Ant のようなビルダー フレームワークに基づくビルド プロセス ユニット ユニット テストの概要 9 Oracle Corporation 発行 Getting Started With Unit-testing の翻訳版です

Clover CVS Anthill Pro http://www.urbancode.com/products/anthillpro Anthill JUnit JUnit.org (http://www.junit.org) Extensions JSP 1 SQL Java SQL SQL 2 SQL Java 10 Oracle Corporation Getting Started With Unit-testing

SQL Java Java 2 TopLink 1 TopLink TopLink SQL TopLink CHECK Java PL/SQL SQL 2 Java - IDE Java 2 PL/SQL Developer Toad 1 11 Oracle Corporation Getting Started With Unit-testing

2 1 jar setter getter Java Bean getter setter getter setter getter setter getter setter CRUD TopLink setter getter - 1 2 CRUD private protected 12 Oracle Corporation Getting Started With Unit-testing

JUnit JUnit http://www.junit.org JUnit Javadoc FAQ Wiki http://c2.com/cgi/wiki?unittest ADF ADF Toy Store Demo http://www.oracle.com/technology/products /jdev/collateral/papers/10g/adftoy store.html 13 Oracle Corporation Getting Started With Unit-testing

: StringUtils substitute() bear true isabear() NULL trimemptytonull() package oracle.code.utils; import java.util.list; import java.util.arraylist; import java.util.stringtokenizer; public class StringUtils private static String BEAR = new String("bear"); private static String EMPTY = new String(""); * * * * in.replaceall(find,newstring) * * @param in: * @param find: * @param newstring: * @return in * newstring public static String substitute (String in, String find, String newstring) // NULL if ( in == null find == null newstring == null) return in; char[] working = in.tochararray(); StringBuffer stringbuffer = new StringBuffer(); // find int startindex = in.indexof(find); if (startindex < 0) return in; int currindex=0; while (startindex > -1) for(int i = currindex; i < startindex; i++) stringbuffer.append(working[i]); 14 Oracle Corporation Getting Started With Unit-testing

currindex = startindex; stringbuffer.append(newstring); currindex += find.length(); startindex = in.indexof(find,currindex); for (int i = currindex; i < working.length; i++) stringbuffer.append(working[i]); return stringbuffer.tostring(); * s "bear" true * * @param s: * @return s "bear" true public static boolean isabear(string s) return BEAR.equals(s); * ""NULL * * @param string: * @return NULL string public static String trimemptytonull (String string) if (string == null EMPTY.equals(string.trim())) return null; return string; 15 Oracle Corporation Getting Started With Unit-testing

: Person Person equal getter setter package oracle.code.model; public class Person private String name; private Integer age; public Person () * * * @param name: * @param age: public Person (String name, Integer age) this.name = name; this.age = age; * * * @param name: public void setname(string name) this.name = name; * * * @return public String getname() return this.name; * * * @param age: public void setage(integer age) this.age = age; * * * @return 16 Oracle Corporation Getting Started With Unit-testing

public Integer getage() return this.age; * * * @param p: * @return this p true public boolean equals(object p) // p this true if (this == p) return true; // p false if (!(p instanceof Person)) return false; // true Person q = (Person)p; return ( (this.name == null? q.name == null: this.name.equals(q.name)) && (this.age == null? q.age == null: this.age.equals(q.age)) ); 17 Oracle Corporation Getting Started With Unit-testing

: StringUtilsTester StringUtils testsubstitute() JDeveloper JUnit New General Unit Tests (JUnit) Test Case Subject Class StringUtilsTester Package Name oracle.code.utils.test Extends junit.framework.testcase package oracle.code.utils.test; import junit.framework.test; import junit.framework.testcase; import junit.framework.testsuite; import oracle.code.utils.stringutils; import oracle.code.model.person; public class StringUtilsTester extends TestCase public StringUtilsTester(String stestname) super (stestname); * String substitute (String, String, String) public void testsubstitute() // A: assertequals("a bear", StringUtils.substitute("a goose", "goose", "bear")); // B: assertequals("a goat", StringUtils.substitute("a goose", "goose", "bear")); // C: // assertequals("substitute goose by bear", "a goat", StringUtils.substitute("a goose", "goose", "bear")); 18 Oracle Corporation Getting Started With Unit-testing

// D: asserttrue/false assertequals("a bear is a bear", true, StringUtils.isABear("bear")); asserttrue("a bear is a bear", StringUtils.isABear("bear")); assertfalse("a goat is not a bear", StringUtils.isABear("goat")); * String trimemptytonull(string) public void testtrimemptytonull() // E: assertnull/assertnotnull assertequals("trim empty string to null is null", null, StringUtils.trimEmptyToNull("")); assertnull("trim empty string to null is null", StringUtils.trimEmptyToNull("")); // trimemptytonull assertnotnull("trim x to null is not null", StringUtils.trimEmptyToNull("x")); 19 Oracle Corporation Getting Started With Unit-testing

: PersonTester Person JUnit JDeveloper JUnit package oracle.code.model.test; import junit.framework.test; import junit.framework.testcase; import junit.framework.testsuite; import oracle.code.model.person; public class PersonTester extends TestCase public PersonTester(String stestname) super(stestname); * boolean equals (Person) public void testequals() // Person jan = new Person("Jan", new Integer(10)); Person piet = new Person("Jan", new Integer(10)); Person joris = new Person("Jan", new Integer(10)); Person fred = new Person(); Person klaas = new Person("Klaas", new Integer(10)); // F: assertequals // assertequals("jan must equal itself", jan, jan); // assertequals("jan equals piet", jan, piet); assertequals("so piet must equal jan", piet, jan); // assertequals("piet equals joris", piet, joris); assertequals("so jan must equal joris", jan, joris); // assertequals("fred equals itself", fred, fred); assertfalse("fred not equals null", fred.equals(null)); assertfalse("jan must not equal klaas", jan.equals(klaas)); // G: assertsame assertsame("fred is same object as fred, fred, fred); assertnotsame("jan is not same as piet", jan, piet); 20 Oracle Corporation Getting Started With Unit-testing

PersonTester StringUtilsTester JUnit 1 JDeveloper JUnit New General Unit Tests (JUnit) Test Suite Class AllTests oracle.code.test Extends java.lang.object Cases Add Suite() JUnit test addtest()addtestsuite() suite() package oracle.code.test; import junit.framework.test; import junit.framework.testsuite; public class AllTests public static Test suite() TestSuite suite = new TestSuite("AllTests"); suite.addtestsuite(oracle.code.model.test.persontester.class); suite.addtestsuite(oracle.code.utils.test.stringutilstester.class); return suite; public static void main (String args[]) String args2 [] = "-noloading", "oracle.code.test.alltests"; junit.swingui.testrunner.main(args2); 21 Oracle Corporation Getting Started With Unit-testing

PersonTester SetUp()tearDown() 2 JUnit test setup() teardown() 1 package oracle.code.model.test; import junit.framework.test; import junit.framework.testcase; import junit.framework.testsuite; import oracle.code.model.person; public class PersonTester extends TestCase private Person jan; private Person piet; private Person joris; private Person fred; private Person klaas; public PersonTester(String stestname) super(stestname); public void setup() this.jan = new Person("Jan", new Integer(10)); this.piet = new Person("Jan", new Integer(10)); this.joris = new Person("Jan", new Integer(10)); this.fred = new Person () ; this.klaas = new Person("Klaas", new Integer(10)); public void teardown() this.jan = null; this.piet = null; this.joris = null; this.fred = null; this.klaas = null; * boolean equals (Person) public void testequals() // F: assertequals // assertequals("jan must equal itself", jan, jan); // assertequals("jan equals piet", jan, piet); assertequals("so piet must equal jan", piet, jan); 22 Oracle Corporation Getting Started With Unit-testing

// assertequals("piet equals joris", piet, joris); assertequals("so jan must equal joris", jan, joris); // assertequals("fred equals itself", fred, fred); assertfalse("fred not equals null", fred.equals(null)); assertfalse("jan must not equal klaas", jan.equals(klaas)); // G: assertsame assertsame("fred is same object as fred", fred, fred); assertnotsame("jan is not same object as piet", jan, piet); ADF ADF ADF HR HR HR ADF JDeveloper JUnit New General Unit Tests (JUnit) Business Components Test Fixture JDBC DataSource JDeveloper J2EE Web/EJB Bundled Exception Mode true 23 Oracle Corporation Getting Started With Unit-testing

package oracle.hr.testfixtures; import oracle.jbo.*; import oracle.jbo.client*; public class HrServicesConnectFixture private static final String AM = "oracle.hr.services.hrservices"; private static final String CF = "HrServicesLocal"; private ApplicationModule applicationmodule; public HrServicesConnectFixture() * public void setup() throws Exception this.applicationmodule = Configuration.createRootApplicationModule(AM, CF); /* * ADF/Struts Bundled Exception Mode this.applicationmodule.gettransaction().setbundledexceptionmode( true ); * public void teardown() throws Exception Configuration.releaseRootApplicationModule(this.applicationModule, true); * * * @return public ApplicationModule getapplicationmodule() return this.applicationmodule; 24 Oracle Corporation Getting Started With Unit-testing

ADF CRUD ADF 1 ManagerId DepartmentId ID package oracle.hr.dataaccess; import junit.framework.test; import junit.framework.testcase; import junit.framework.testsuite; import oracle.hr.testfixtures.hrservicesconnectfixture; import oracle.jbo.jboexception; import oracle.jbo.key; import oracle.jbo.viewobject; import oracle.jbo.row; public class DepartmentsTests extends TestCase private static String DEPARTMENTID = "DepartmentId"; private static String DEPARTMENTNAME = "DepartmentName"; private static String MANAGERID = "ManagerId"; private static String LOCATIONID = "LocationId"; HrServicesConnectFixture connectionfixture = new HrServicesConnectFixture(); public DepartmentsTests (String stestname) super(stestname); public void testdepartmentsviewobjectlifecycle() ViewObject departmentsview = this.connectionfixture.getapplicationmodule().findviewobject( "Depart ments"); * NULL assertnotnull(departmentsview); * Row departmentrow = departmentsview.createrow(); try 25 Oracle Corporation Getting Started With Unit-testing

departmentrow.setattribute(this.departmentid, "1"); departmentrow.setattribute(this.departmentname, "test department"); departmentrow.setattribute(this.managerid, "100"); departmentrow.setattribute(this.locationid, "1000"); catch (JboException jbo) fail("should not have thrown this " + jbo.getclass().getname() + " exception yet due to bundled exception mode"); this.connectionfixture.getapplicationmodule().gettransaction(). commit(); * Row[] departmentrows = new Row[0]; try Key key = departmentrow.getkey(); departmentrows = departmentsview.findbykey(key, 1); assertequals("expect to find one department with id 1", departmentrows.length, 1) ; catch (JboException jbo) fail("should not have thrown this " + jbo.getclass().getname() + " exception yet due to bundled exception mode"); * try departmentrows[0].setattribute(this.departmentname, "testing department"); this.connectionfixture.getapplicationmodule().gettransaction(). commit(); catch (JboException jbo) fail("should not have thrown this " + jbo.getclass().getname() + " exception yet due to bundled exception mode"); * try 26 Oracle Corporation Getting Started With Unit-testing

departmentrows[0].remove(); this.connectionfixture.getapplicationmodule().gettransaction(). commit(); catch (JboException jbo) fail("should not have thrown this " + jbo.getclass().getname() + " exception yet due to bundled exception mode"); public void setup() throws Exception this.connectionfixture.setup(); public void teardown() throws Exception this.connectionfixture.teardown(); 27 Oracle Corporation Getting Started With Unit-testing

2004 12 : Jan Kettenis, Remco de Blok Oracle Corporation World Headquarters 500 Oracle Parkway Redwood Shores, CA 94065 U.S.A. : : +1.650.506.7000 : +1.650.506.7200 www.oracle.com Copyright 2004, Oracle. All rights reserved. Oracle Oracle Corporation