<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1076369395379934366</id><updated>2024-10-07T14:24:45.050+09:00</updated><category term="JUnit"/><category term="Java"/><category term="camera"/><category term="photo"/><title type='text'>siglog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://siguremon.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1076369395379934366/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://siguremon.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>siguremon</name><uri>http://www.blogger.com/profile/05745965265092829532</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi155YeSvo2C4eIieq5bCMnLu1x3hG7MZEGAv6kwBEnRZNRQHJGnO6jsHB2FIb2NhwGQ9bV9RdIT0xMzVtF7txwLnmVyV6OgEpTO2vS4sXZn_wxryoJ-ivgziyYWlYdCw/s220/profile.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1076369395379934366.post-9151246820341292829</id><published>2013-07-26T10:46:00.001+09:00</published><updated>2013-07-26T10:46:56.430+09:00</updated><title type='text'>Title</title><content type='html'>&lt;h1 id=&quot;stackedit&quot;&gt;StackEditで投稿テスト&lt;/h1&gt;

&lt;p&gt;ChromeアプリのStackEditなら、Markdownで描いてbloggerに投稿できるらしいので、
試してみます。&lt;/p&gt;

&lt;p&gt;StackEditは以下を参照してください。&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Written with &lt;a href=&quot;http://benweet.github.io/stackedit/&quot;&gt;StackEdit&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://siguremon.blogspot.com/feeds/9151246820341292829/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://siguremon.blogspot.com/2013/07/title.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1076369395379934366/posts/default/9151246820341292829'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1076369395379934366/posts/default/9151246820341292829'/><link rel='alternate' type='text/html' href='http://siguremon.blogspot.com/2013/07/title.html' title='Title'/><author><name>siguremon</name><uri>http://www.blogger.com/profile/05745965265092829532</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi155YeSvo2C4eIieq5bCMnLu1x3hG7MZEGAv6kwBEnRZNRQHJGnO6jsHB2FIb2NhwGQ9bV9RdIT0xMzVtF7txwLnmVyV6OgEpTO2vS4sXZn_wxryoJ-ivgziyYWlYdCw/s220/profile.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1076369395379934366.post-7758424373303088336</id><published>2012-11-02T06:48:00.001+09:00</published><updated>2013-01-05T16:59:49.744+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="JUnit"/><title type='text'>JUnit入門―導入・実行編(Ant ver.)</title><content type='html'>今回はJUnitをAntから使うための環境について試してみます。&lt;br /&gt;&lt;br /&gt;使用している環境は以下の通りです。&lt;br /&gt;それぞれ、JDK・JUnitは導入済みとします。&lt;br /&gt;・Windows 7 SP1&lt;br /&gt;・JDK 1.7.0 (64bit ver.)&lt;br /&gt;・JUnit 4.10&lt;br /&gt;
&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;strong&gt;・Antの導入&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
Antとは、Javaベースのビルドツールの1つで、build.xmlというファイルにxml形式で目的ごとの処理を記述していきます。&lt;br /&gt;
導入の方法としては、バイナリを手に入れる方法とソースからビルドする方法があります。&lt;br /&gt;
ここでは、バイナリを使用する方法について説明します。  &lt;br /&gt;
まず、Antのバイナリを以下のページからzipファイルをダウンロードします。&lt;br /&gt;&lt;a href=&quot;http://ant.apache.org/bindownload.cgi&quot;&gt;http://ant.apache.org/bindownload.cgi&lt;/a&gt;&lt;br /&gt;
zipファイルを適当なところに展開しておきます。&lt;br /&gt;次に環境変数を設定します。&lt;br /&gt;設定の必要があるのは、以下の3つです。&lt;br /&gt;
&lt;blockquote&gt;
JAVA_HOME　・・・JDKがインストールされているフォルダ。&lt;br /&gt;ANT_HOME　・・・Antがインストールされているフォルダ&lt;br /&gt;PATH　・・・Antの実行ファイルがあるフォルダを追加する。ANT_HOME以下のbinに実行ファイルがある&lt;/blockquote&gt;
以上で導入は完了です。&lt;br /&gt;コマンドプロンプトを開いて、以下のコマンドを実行したときにバージョン番号等が表示されればOKです。&lt;br /&gt;
&lt;blockquote&gt;
ant -version&lt;/blockquote&gt;
&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;strong&gt;・1分で分かった気になるAnt&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
Antでは、「ビルドする」・「テストする」などの目的を「ターゲット」、目的を達成するために実行する「フォルダを作成する」・「javacを実行する」などの個々の処理を「タスク」と呼んでいて、ターゲットごとにいくつかのタスクを実行します。&lt;br /&gt;以下がbuild.xmlの簡単なサンプルです。&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/2721278.js?file=build.xml&quot;&gt;&lt;/script&gt; &lt;br /&gt;
&lt;br /&gt;これは「SimpleAnt」という名前のプロジェクトのためのbuild.xmlで、「compile」「test」という2つのターゲットを持っています。&lt;br /&gt;「compile」と「test」のそれぞれのターゲットでは、「echo」というタスクを実行するように指定しています。&lt;br /&gt;このタスクは文字列を表示するだけの単純なタスクです。&lt;br /&gt;2行目でデフォルトを「compile」に指定しているため、ターゲットを指定せずにAntを実行した場合、自動的に「compile」ターゲットのタスクを実行します。&lt;br /&gt;実行するときは、build.xmlがあるフォルダでantコマンドを実行します。&lt;br /&gt;
&lt;blockquote&gt;
C:\Users\siguremon&amp;gt;ant&lt;br /&gt;Buildfile: C:\Users\siguremon\build.xml&lt;br /&gt;compile:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [echo] compileだけど表示するだけで何もしない&lt;br /&gt;BUILD SUCCESSFULTotal time: 0 seconds&lt;/blockquote&gt;
また、「test」ターゲットでは6行目で依存関係に「compile」を指定しています。&lt;br /&gt;そのため、Antで「test」を指定して実行すると、以下のように「test」のタスクの前に「compile」のタスクが実行されます。&lt;br /&gt;
&lt;blockquote&gt;
C:\Users\siguremon&amp;gt;ant test&lt;br /&gt;Buildfile: C:\Users\siguremon\build.xml&lt;br /&gt;compile:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [echo] compileだけど表示するだけで何もしない&lt;br /&gt;test:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [echo] testだけど表示するだけで何もしない&lt;br /&gt;BUILD SUCCESSFULTotal time: 0 seconds&lt;/blockquote&gt;
&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;strong&gt;・JUnitを使うためのbuild.xmlの記述&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
AntからJUnitを使うためには、3つのポイントがあります。&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;junitタスクを使ってテストを実行する （単一のテストクラスを指定）  &lt;/li&gt;
&lt;li&gt;junitタスクを使ってテストを実行する （複数のテストクラスを指定）  &lt;/li&gt;
&lt;li&gt;junitreportタスクを使ってテストの実行結果を整形する&lt;/li&gt;
&lt;/ol&gt;
&lt;strong&gt;&lt;u&gt;1.junitタスクを使ってテストを実行する（単一のテストクラスを指定）&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;pre&gt;単一のテストクラスを指定する場合には、以下のように&amp;lt;test&amp;gt;プロパティを使います。
この場合、my.test.TestCaseがテストクラスです。&lt;/pre&gt;
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;&amp;lt;junit printsummary=&quot;yes&quot; fork=&quot;yes&quot; haltonfailure=&quot;yes&quot;&amp;gt;
  &amp;lt;formatter type=&quot;plain&quot; /&amp;gt;
  &amp;lt;test name=&quot;my.test.TestCase&quot; /&amp;gt;
&amp;lt;/junit&amp;gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;pre&gt;その他、&amp;lt;formatter&amp;gt;プロパティでjunitの出力形式を指定しています。&lt;/pre&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;u&gt;2.junitタスクを使ってテストを実行する（複数のテストクラスを指定）&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
複数のテストクラスを指定する場合には、以下のように&amp;lt;batchtest&amp;gt;プロパティを使います。&lt;br /&gt;&amp;lt;batchtest&amp;gt;プロパティの中では、filesetでテストクラスを指定します。&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;&amp;lt;junit printsummary=&quot;yes&quot; haltonfailure=&quot;yes&quot;&amp;gt;
  &amp;lt;classpath&amp;gt;
    &amp;lt;pathelement location=&quot;${build.tests}&quot; /&amp;gt;
    &amp;lt;pathelement path=&quot;${java.class.path}&quot; /&amp;gt;
  &amp;lt;/classpath&amp;gt;

  &amp;lt;formatter type=&quot;plain&quot; /&amp;gt;

  &amp;lt;batchtest fork=&quot;yes&quot; todir=&quot;${reports.tests}&quot;&amp;gt;
    &amp;lt;fileset dir=&quot;${src.tests}&quot;&amp;gt;
      &amp;lt;include name=&quot;**/*Test*.java&quot; /&amp;gt;
      &amp;lt;exclude name=&quot;**/AllTests.java&quot; /&amp;gt;
    &amp;lt;/fileset&amp;gt;
  &amp;lt;/batchtest&amp;gt;
&amp;lt;/junit&amp;gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;u&gt;3.junitreportタスクを使ってテストの実行結果を整形する&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
junitの実行結果は上でも少し触れましたが、&amp;lt;formatter&amp;gt;プロパティで指定することができます。&lt;br /&gt;デフォルトでは&quot;plain&quot;、&quot;brief”、&quot;xml&quot;の3つを指定することができます。&lt;br /&gt;しかし、junitreportタスクを使うとさらに結果を見やすくすることができます。&lt;br /&gt;このタスクを使うためには、junitの&amp;lt;formatter&amp;gt;プロパティで&quot;xml&quot;を指定する必要があります。&lt;br /&gt;その上で、出力結果ファイルを&amp;lt;fileset&amp;gt;で指定し、&amp;lt;report&amp;gt;で最後に出力します。&lt;br /&gt;
&lt;pre&gt;&amp;lt;junitreport todir=&quot;./reports&quot;&amp;gt;
  &amp;lt;fileset dir=&quot;./reports&quot;&amp;gt;
    &amp;lt;include name=&quot;TEST-*.xml&quot;/&amp;gt;
  &amp;lt;/fileset&amp;gt;
  &amp;lt;report format=&quot;frames&quot; todir=&quot;./report/html&quot;/&amp;gt;
&amp;lt;/junitreport&amp;gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;strong&gt;・サンプル&lt;/strong&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;以下にサンプルを置きました。
複数のテストクラスを実行し、junitreportで整形した出力結果を作成しています。&lt;/pre&gt;
&lt;pre&gt;&lt;a href=&quot;https://github.com/siguremon/AntExample/tree/simpleant&quot;&gt;https://github.com/siguremon/AntExample/tree/simpleant&lt;/a&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;strong&gt;・参考&lt;/strong&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;a href=&quot;http://www.techscore.com/tech/Java/ApacheJakarta/Ant/index/&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.techscore.com/tech/Java/ApacheJakarta/Ant/index/&quot;&gt;Ant | TECHSCORE（テックスコア）&lt;/a&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;a href=&quot;http://www.techscore.com/tech/Java/ApacheJakarta/Ant/index/&quot;&gt;JUnit Task&lt;/a&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;a href=&quot;http://www.jajakarta.org/ant/ant-1.5/docs/ant-1.5/j/docs/manual/OptionalTasks/junitreport.html&quot;&gt;JUnitReportタスク&lt;/a&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://siguremon.blogspot.com/feeds/7758424373303088336/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://siguremon.blogspot.com/2012/11/junitant-ver.html#comment-form' title='1 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1076369395379934366/posts/default/7758424373303088336'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1076369395379934366/posts/default/7758424373303088336'/><link rel='alternate' type='text/html' href='http://siguremon.blogspot.com/2012/11/junitant-ver.html' title='JUnit入門―導入・実行編(Ant ver.)'/><author><name>siguremon</name><uri>http://www.blogger.com/profile/05745965265092829532</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi155YeSvo2C4eIieq5bCMnLu1x3hG7MZEGAv6kwBEnRZNRQHJGnO6jsHB2FIb2NhwGQ9bV9RdIT0xMzVtF7txwLnmVyV6OgEpTO2vS4sXZn_wxryoJ-ivgziyYWlYdCw/s220/profile.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1076369395379934366.post-8128196504668294518</id><published>2012-04-07T00:41:00.000+09:00</published><updated>2012-11-02T06:48:35.480+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="JUnit"/><title type='text'>JUnit入門―導入・実行編(コンソールver.)</title><content type='html'>&lt;div&gt;
&lt;br /&gt;
今回は、JUnitをコンソールから使うための環境作りについて試してみます。&lt;br /&gt;
ここでは、JDKはすでにインストールされているものとします。&lt;br /&gt;
JDKのインストールについては、以下のページなどを参考にしてみてください。&lt;br /&gt;
&lt;br /&gt;
http://www.javadrive.jp/install/jdk/&lt;br /&gt;
&lt;br /&gt;
使用している環境は以下の通りです。&lt;br /&gt;
・Windows 7 SP1&lt;br /&gt;
・JDK 1.7.0 (64bit ver.)&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;・JUnitの導入&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
まず、JUnitのJarファイルなどをダウンロードします。&lt;br /&gt;
&lt;br /&gt;
現時点(2012/3)での最新版である4.10は、github上にあります。&lt;br /&gt;
github上には、4.7までのJUnitをダウンロードすることができるようになっています。&lt;br /&gt;
&lt;a href=&quot;https://github.com/KentBeck/junit/downloads&quot;&gt;https://github.com/KentBeck/junit/downloads&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
それより以前のバージョンのものはsorceforgeにあります。&lt;br /&gt;
よく見ると、sorceforge上にも4.10まであるようです。&lt;br /&gt;
&lt;a href=&quot;http://sourceforge.net/projects/junit/files/junit/&quot;&gt;http://sourceforge.net/projects/junit/files/junit/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
上記ページから、zipファイルかtarファイルをダウンロードして、適当なところに展開します。&lt;br /&gt;
ここでは比較のため、4.10と3.8.1をダウンロードします。&lt;br /&gt;
それぞれ、「junit4.10」、「junit3.8.1」というディレクトリに展開すると、各ディレクトリ直下に「junit-4.10.jar」または「junit.jar」があります。&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;・テストの実行&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
3.x系と4.x系で実行の仕方が大きく異なります。&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;3.x系&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
3.x系では、CUIで実行する方法・swingのGUIで実行する方法・awtのGUIで実行する方法の3週類があります。&lt;br /&gt;
ここでは、junitに付属しているサンプルをそれぞれの方法で実行してみます。&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1.CUIで実行する方法&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
先程展開したディレクトリで、以下のコマンドを実行します。&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
\junit3.8.1&amp;gt; java -cp junit.jar;. junit.textui.TestRunner junit.samples.SimpleTest&lt;/blockquote&gt;
&lt;br /&gt;
junit.texui.TestRunnerというものがテストクラス実行のためのクラス（テストランナー）になります。&lt;br /&gt;
その後に、テストクラス名を引数で指定します。&lt;br /&gt;
テストクラスは1つしか指定できないようです。&lt;br /&gt;
実行結果は以下のようになります。&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
.E.F.F&lt;br /&gt;
Time: 0.002&lt;br /&gt;
There was 1 error:&lt;br /&gt;
1) testDivideByZero(junit.samples.SimpleTest)java.lang.ArithmeticException: / by zero&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.samples.SimpleTest.testDivideByZero(SimpleTest.java:49)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)&lt;br /&gt;
There were 2 failures:&lt;br /&gt;
1) testEquals(junit.samples.SimpleTest)junit.framework.AssertionFailedError: Size expected:&amp;lt;12&amp;gt; but was:&amp;lt;13&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.samples.SimpleTest.testEquals(SimpleTest.java:56)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)&lt;br /&gt;
2) testAdd(junit.samples.SimpleTest)junit.framework.AssertionFailedError&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.samples.SimpleTest.testAdd(SimpleTest.java:45)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)&lt;br /&gt;
FAILURES!!!&lt;br /&gt;
Tests run: 3, &amp;nbsp;Failures: 2, &amp;nbsp;Errors: 1&lt;/blockquote&gt;
&lt;br /&gt;
3つのテストケースを実行して、検証の失敗（Failures）が2つ、実行時のエラー（Errors）が１つという結果になっています。&lt;br /&gt;
失敗とエラーの違いは、assertionによる例外か、それ以外の例外かというものです。&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2.swingのGUIで実行する方法&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
先程と同様にjunitのディレクトリで、以下のコマンドを実行します。&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
\junit3.8.1&amp;gt; java -cp junit.jar;. junit.swingui.TestRunner junit.samples.SimpleTest&lt;/blockquote&gt;
&lt;br /&gt;
すると、以下のようなGUIが表示されます。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUq7H8z2i43uHhWFKMAZ4Hq9btPXHlofH1lKMqokvxcgMf-AEyp62fdVCti3CoapLNg_pAombtVqQSr8TbSaq62EHwz3Nuv99k2ck_rBMOcK3-JMf1mmxiJvAu2bdAfUa9a5L9lJ-FT5A/s1600/swingui.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUq7H8z2i43uHhWFKMAZ4Hq9btPXHlofH1lKMqokvxcgMf-AEyp62fdVCti3CoapLNg_pAombtVqQSr8TbSaq62EHwz3Nuv99k2ck_rBMOcK3-JMf1mmxiJvAu2bdAfUa9a5L9lJ-FT5A/s400/swingui.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
結果は先ほどと同様ですが、中央に赤いバーが表示されていて、結果を視覚的に確認することができます。&lt;br /&gt;
また、上段の「Run」ボタンを押下するとテストクラスの再実行が、中段の「Run」を押下すると各テストケースごとの実行ができます。&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3.awtのGUIで実行する方法&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
awtの場合も、swingと同様の実行法になります。&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
\junit3.8.1&amp;gt; java -cp junit.jar;. junit.awtgui.TestRunner junit.samples.SimpleTest&lt;/blockquote&gt;
&lt;br /&gt;
すると、以下のようなGUIが表示されます。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPsU43JGFLc2T8TkWS_7cbuscft2Lcku5Qh-XJAMgCKSFvgNknHH7AED10iIALN37rLep8OMQpAW4kUTNShUDOL9D3hStLfhWO0fKgEzFnVD9UJMeep9A0iojqT4cEINmK0R3orAGF7k8/s1600/awtui.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;347&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPsU43JGFLc2T8TkWS_7cbuscft2Lcku5Qh-XJAMgCKSFvgNknHH7AED10iIALN37rLep8OMQpAW4kUTNShUDOL9D3hStLfhWO0fKgEzFnVD9UJMeep9A0iojqT4cEINmK0R3orAGF7k8/s400/awtui.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
こちらのGUIでもテストクラスの再実行とテストケースごとの実行ができるようになっています。&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;4.x系&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
4.x系では、3.x系のようなGUIのテストランナーのクラスは用意されていません。&lt;br /&gt;
さらに、コマンドライン上で実行するためのテストランナークラスも変更されています。&lt;br /&gt;
コマンドは以下の通りです。&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
\junit4.10&amp;gt; java -cp junit-4.10.jar;. org.junit.runner.JUnitCore junit.samples.SimpleTest&lt;/blockquote&gt;
&lt;br /&gt;
こちらでは「org.junit.runner.JUnitCore」というクラスがテストランナーになっています。&lt;br /&gt;
出力結果も若干変わっています。&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
JUnit version 4.10&lt;br /&gt;
.E.E.E&lt;br /&gt;
Time: 0.005&lt;br /&gt;
There were 3 failures:&lt;br /&gt;
1) testDivideByZero(junit.samples.SimpleTest)&lt;br /&gt;
java.lang.ArithmeticException: / by zero&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.samples.SimpleTest.testDivideByZero(SimpleTest.java:54)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at java.lang.reflect.Method.invoke(Unknown Source)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestCase.runTest(TestCase.java:168)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestCase.runBare(TestCase.java:134)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestResult$1.protect(TestResult.java:110)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestResult.runProtected(TestResult.java:128)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestResult.run(TestResult.java:113)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestCase.run(TestCase.java:124)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestSuite.runTest(TestSuite.java:243)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestSuite.run(TestSuite.java:238)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.Suite.runChild(Suite.java:128)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.Suite.runChild(Suite.java:24)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner.run(ParentRunner.java:300)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.run(JUnitCore.java:157)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.run(JUnitCore.java:136)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.run(JUnitCore.java:117)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.runMain(JUnitCore.java:98)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.runMainAndExit(JUnitCore.java:53)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.main(JUnitCore.java:45)&lt;br /&gt;
2) testAdd(junit.samples.SimpleTest)&lt;br /&gt;
junit.framework.AssertionFailedError&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.Assert.fail(Assert.java:48)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.Assert.assertTrue(Assert.java:20)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.Assert.assertTrue(Assert.java:27)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.samples.SimpleTest.testAdd(SimpleTest.java:48)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at java.lang.reflect.Method.invoke(Unknown Source)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestCase.runTest(TestCase.java:168)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestCase.runBare(TestCase.java:134)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestResult$1.protect(TestResult.java:110)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestResult.runProtected(TestResult.java:128)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestResult.run(TestResult.java:113)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestCase.run(TestCase.java:124)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestSuite.runTest(TestSuite.java:243)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestSuite.run(TestSuite.java:238)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.Suite.runChild(Suite.java:128)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.Suite.runChild(Suite.java:24)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner.run(ParentRunner.java:300)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.run(JUnitCore.java:157)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.run(JUnitCore.java:136)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.run(JUnitCore.java:117)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.runMain(JUnitCore.java:98)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.runMainAndExit(JUnitCore.java:53)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.main(JUnitCore.java:45)&lt;br /&gt;
3) testEquals(junit.samples.SimpleTest)&lt;br /&gt;
junit.framework.AssertionFailedError: Size expected:&amp;lt;12&amp;gt; but was:&amp;lt;13&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.Assert.fail(Assert.java:50)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.Assert.failNotEquals(Assert.java:287)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.Assert.assertEquals(Assert.java:67)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.Assert.assertEquals(Assert.java:199)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.samples.SimpleTest.testEquals(SimpleTest.java:62)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at java.lang.reflect.Method.invoke(Unknown Source)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestCase.runTest(TestCase.java:168)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestCase.runBare(TestCase.java:134)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestResult$1.protect(TestResult.java:110)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestResult.runProtected(TestResult.java:128)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestResult.run(TestResult.java:113)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestCase.run(TestCase.java:124)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestSuite.runTest(TestSuite.java:243)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at junit.framework.TestSuite.run(TestSuite.java:238)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.Suite.runChild(Suite.java:128)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.Suite.runChild(Suite.java:24)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runners.ParentRunner.run(ParentRunner.java:300)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.run(JUnitCore.java:157)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.run(JUnitCore.java:136)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.run(JUnitCore.java:117)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.runMain(JUnitCore.java:98)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.runMainAndExit(JUnitCore.java:53)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at org.junit.runner.JUnitCore.main(JUnitCore.java:45)&lt;br /&gt;
FAILURES!!!&lt;br /&gt;
Tests run: 3, &amp;nbsp;Failures: 3&lt;/blockquote&gt;
&lt;br /&gt;
大きな違いとしては、Errorsがなくなり、すべてFailuresに統一されている点でしょうか。&lt;br /&gt;
あとは、バージョン番号なんかも表示されるようになっていますね。&lt;br /&gt;
&lt;br /&gt;
なお、4.x系では引数のテストクラスを複数指定することができるようになっています。&lt;br /&gt;
以下のように、引数にテストクラスを指定していけば、全て実行してくれます。&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
\junit4.10&amp;gt; java -cp junit-4.10.jar;. org.junit.runner.JUnitCore junit.samples.SimpleTest&lt;/blockquote&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://siguremon.blogspot.com/feeds/8128196504668294518/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://siguremon.blogspot.com/2012/04/junitver.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1076369395379934366/posts/default/8128196504668294518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1076369395379934366/posts/default/8128196504668294518'/><link rel='alternate' type='text/html' href='http://siguremon.blogspot.com/2012/04/junitver.html' title='JUnit入門―導入・実行編(コンソールver.)'/><author><name>siguremon</name><uri>http://www.blogger.com/profile/05745965265092829532</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi155YeSvo2C4eIieq5bCMnLu1x3hG7MZEGAv6kwBEnRZNRQHJGnO6jsHB2FIb2NhwGQ9bV9RdIT0xMzVtF7txwLnmVyV6OgEpTO2vS4sXZn_wxryoJ-ivgziyYWlYdCw/s220/profile.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUq7H8z2i43uHhWFKMAZ4Hq9btPXHlofH1lKMqokvxcgMf-AEyp62fdVCti3CoapLNg_pAombtVqQSr8TbSaq62EHwz3Nuv99k2ck_rBMOcK3-JMf1mmxiJvAu2bdAfUa9a5L9lJ-FT5A/s72-c/swingui.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1076369395379934366.post-4018411712148045774</id><published>2012-03-13T00:20:00.001+09:00</published><updated>2012-03-13T00:20:46.231+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="JUnit"/><title type='text'>JUnit入門―導入・実行編（Eclipse ver.）</title><content type='html'>&lt;div&gt;
まずは、JUnitを使うための環境作りについて見ていきます。&lt;/div&gt;
&lt;div&gt;
JUnitを利用するためには、IDEを利用する方法やビルドツールを利用する方法などがあります。&lt;/div&gt;
&lt;div&gt;
今回は、最も簡単な利用方法だと思われるEclipseを使った方法を試してみます。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
使用している環境はPleiades All in One 3.7.2（Eclipse3.7.2をベースに日本語化したもの）です。&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;・JUnitの導入&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
Eclipseには最初からJUnitが含まれているため、インストールの必要はありません。&lt;/div&gt;
&lt;div&gt;
また、JUnitのテストクラスを実行して結果を確認するためのプラグインも含まれていて、至れり尽くせりです。&lt;/div&gt;
&lt;div&gt;
そのため、ビルドパスはJUnitのライブラリを追加して、テストクラスを作成すればすぐに実行して結果を確認することができます。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
ということで、まずはプロジェクトにJUnitのライブラリを追加します。&lt;/div&gt;
&lt;div&gt;
（プロジェクトはすでにあるものとします。）&lt;/div&gt;
&lt;div&gt;
パッケージ・エクスプローラーのプロジェクトを右クリックして、「ビルド・パス→ライブラリの追加」を選択すると、以下のようなライブラリ選択画面になります。&lt;/div&gt;
&lt;div&gt;
そこで、JUnitを選択して次に進みます。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXAlacOVt1wUqqabHYyAqaeu7EuBRdbWkc9tL4HPlCnvdFD8RyEVEmvr4AKh6U7fjShHNQVPqrPj3DLVhyvsnGDJLaFPV0Tg15fux4CZ7y2HNMcxhipYuwsNEWXWwsi3CjCKkhAtWjyYc/s1600/add_lib01.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;387&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXAlacOVt1wUqqabHYyAqaeu7EuBRdbWkc9tL4HPlCnvdFD8RyEVEmvr4AKh6U7fjShHNQVPqrPj3DLVhyvsnGDJLaFPV0Tg15fux4CZ7y2HNMcxhipYuwsNEWXWwsi3CjCKkhAtWjyYc/s640/add_lib01.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;JUnitライブラリの追加(1）&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
次に進むと、ライブラリのバージョンを選択する画面になります。&lt;br /&gt;
ここではJUnit4を選択しています。&lt;br /&gt;
今回の環境ではJUnitのソースは含まれていないので、ソース・ロケーションが「見つかりません」となっているようです。&lt;br /&gt;
これで完了を押せばOKです。&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRqBZPayPviV1Uo2jM3_2IvqxoCT4e-kj0VcnvMVL27UR08F_PJme9r0DpVdyIVuuFG85ZZ4YURhc5F_z_OBv_drJ5mDjt-5gfcL08zoMfIWfz1jfvb4z4q2_yh3dFrhJ6cC0Gp9tFJpg/s1600/add_lib02.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;388&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRqBZPayPviV1Uo2jM3_2IvqxoCT4e-kj0VcnvMVL27UR08F_PJme9r0DpVdyIVuuFG85ZZ4YURhc5F_z_OBv_drJ5mDjt-5gfcL08zoMfIWfz1jfvb4z4q2_yh3dFrhJ6cC0Gp9tFJpg/s640/add_lib02.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;JUnitライブラリの追加(2)　バージョンの選択&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;・テストの実行&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
JUnitライブラリの準備ができたので、次にテストクラスを作って実行してみます。&lt;br /&gt;
テストクラスの作成も、IDEによるサポートがあるため、簡単に作ることができます。&lt;br /&gt;
&lt;br /&gt;
ここではテスト対象のクラスとして、以下のCalcクラスがプロジェクトに含まれているとします。&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/1961347.js&quot;&gt;
 
&lt;/script&gt;
&lt;br /&gt;
パッケージ・エクスプローラー上のCalcクラスを右クリックして、「新規→JUnitテスト・ケース」と選択すると、以下のテスト・ケース作成画面になります。&lt;br /&gt;
この時点で、一通りのデフォルト値が入力された状態になっています。&lt;br /&gt;
名前はテスト対象のクラスに”Test”と付けたものになり、テスト元クラスが先程のCalcクラスになっています。&lt;br /&gt;
クラスを選択せずに新規作成すると、名前やテスト元クラスのデフォルト値は空になります。&lt;br /&gt;
&lt;br /&gt;
また、メソッドのスタブを作成するかどうかもここで選ぶことができます。&lt;br /&gt;
以下の画面では、setUpメソッドとtearDownメソッドを選択しています。&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1_yKQ5hogfiY-jXGTYfBvRzmgqYbSvcjdq0Cq8cSOm_umYCsjV9y5h6MzuEC7wb0dx6oGug-FaLMdb2RRCV3k9pH6dJTnZNi9ML5jWzyYZTrAmLvOq-z7w6BmmOoCk9I2uCBiVOnfFHs/s1600/gen_testclass01.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;442&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1_yKQ5hogfiY-jXGTYfBvRzmgqYbSvcjdq0Cq8cSOm_umYCsjV9y5h6MzuEC7wb0dx6oGug-FaLMdb2RRCV3k9pH6dJTnZNi9ML5jWzyYZTrAmLvOq-z7w6BmmOoCk9I2uCBiVOnfFHs/s640/gen_testclass01.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;JUnitテスト・ケース（テストクラス）の追加&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
次に進むと、テストの対象とするメソッドを選択する画面になります。&lt;br /&gt;
&lt;div&gt;
テスト対象クラスのメソッド一覧が表示されているので、どれをテストするかを選択します。&lt;/div&gt;
&lt;div&gt;
以下の画面では、Calcクラスのsumメソッドのみを選択しています。&lt;/div&gt;
&lt;div&gt;
これで完了を押すと、テストクラスがプロジェクトに追加されます。&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkvIpBEGT2VDIbScZ9MtQOP6o281PtePDjZUBas4cMpIEUarNMvQjDGPKjGFod8ojVaowQWz7tIR3EOLhwyTZo3KwbcUueHt6lfBQrO3O9rWuMBJbC9ct8axwzmM6Vn5zWgbGFaehFj5k/s1600/gen_testclass02.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;442&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkvIpBEGT2VDIbScZ9MtQOP6o281PtePDjZUBas4cMpIEUarNMvQjDGPKjGFod8ojVaowQWz7tIR3EOLhwyTZo3KwbcUueHt6lfBQrO3O9rWuMBJbC9ct8axwzmM6Vn5zWgbGFaehFj5k/s640/gen_testclass02.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;JUnitテスト・ケースでの対象メソッド選択&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
追加されたテストクラスは以下のようなものになっているはずです。（画像右側のCalcTest.java）&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
setUp、tearDown、testSumの3つのメソッドがあります。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
テストメソッドは、対象のメソッド名の前に”test”と付けた名前になります。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
中身はまだ実装されていないので、必ず失敗するコードが書かれています。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
このテストクラスを実行するためには、メニューから「実行→実行」を選択します。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
もしくは「Ctrl+F11」でも実行できます。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
実行すると、左側にJUnitの実行結果が現れます。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
今回は1つのテストケース（メソッド）を実行し、そのテストが失敗していることを示しています。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
失敗すると、バーが赤く表示されます。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR11_oOFXQKawQ9jBHOqx5u6_xmNGMcb-fF0Uoz5Guna3bn09X8oImH2ZFYPmLkPFdTvhVuHBhkIRhP4aq4c7KEA3bCndR3Jww026rhhxUKYFfZASFOZGrmDJHYG-Sy3ETgJnwnnMluy4/s1600/do_test01.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR11_oOFXQKawQ9jBHOqx5u6_xmNGMcb-fF0Uoz5Guna3bn09X8oImH2ZFYPmLkPFdTvhVuHBhkIRhP4aq4c7KEA3bCndR3Jww026rhhxUKYFfZASFOZGrmDJHYG-Sy3ETgJnwnnMluy4/s640/do_test01.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;テスト・ケースの実行（失敗）&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
では、次にテストケースの中身を以下のように書き換えてみます。&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/1961352.js&quot;&gt;
 
&lt;/script&gt;&lt;br /&gt;
詳細は省略しますが、Calcクラスのsumメソッドを使って、「sum(1,2)」が正しく「3」になるかどうかを確認するように書き換えています。&lt;/div&gt;
&lt;div&gt;
これをもう一度実行すると、今度はバーの部分が緑色に変わります。&lt;/div&gt;
&lt;div&gt;
これで、「sum(1,2)=1+2=3」が確認できたことになります。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcTXwwVHMxI4cymE1bwkR9hTBvScVOoaf9j83Z-nYtKsQ2hzMvSxmdXVaJBI0Sqtf4JXAgp8o1LJjUy_inMwnDbYMMQ00UT7mIoYno44yyw2u6RgwiAlH8eQTgzdZmtgqrkocOcLAFXbc/s1600/do_test02.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcTXwwVHMxI4cymE1bwkR9hTBvScVOoaf9j83Z-nYtKsQ2hzMvSxmdXVaJBI0Sqtf4JXAgp8o1LJjUy_inMwnDbYMMQ00UT7mIoYno44yyw2u6RgwiAlH8eQTgzdZmtgqrkocOcLAFXbc/s640/do_test02.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;テスト・ケースの実行（成功）&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
以上のように、Ecpliseではかなりお手軽にJUnitの導入と実行ができるようになっています。&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://siguremon.blogspot.com/feeds/4018411712148045774/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://siguremon.blogspot.com/2012/03/juniteclipse-ver.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1076369395379934366/posts/default/4018411712148045774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1076369395379934366/posts/default/4018411712148045774'/><link rel='alternate' type='text/html' href='http://siguremon.blogspot.com/2012/03/juniteclipse-ver.html' title='JUnit入門―導入・実行編（Eclipse ver.）'/><author><name>siguremon</name><uri>http://www.blogger.com/profile/05745965265092829532</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi155YeSvo2C4eIieq5bCMnLu1x3hG7MZEGAv6kwBEnRZNRQHJGnO6jsHB2FIb2NhwGQ9bV9RdIT0xMzVtF7txwLnmVyV6OgEpTO2vS4sXZn_wxryoJ-ivgziyYWlYdCw/s220/profile.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXAlacOVt1wUqqabHYyAqaeu7EuBRdbWkc9tL4HPlCnvdFD8RyEVEmvr4AKh6U7fjShHNQVPqrPj3DLVhyvsnGDJLaFPV0Tg15fux4CZ7y2HNMcxhipYuwsNEWXWwsi3CjCKkhAtWjyYc/s72-c/add_lib01.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1076369395379934366.post-3488584324813951386</id><published>2012-03-03T07:15:00.001+09:00</published><updated>2012-03-03T07:15:11.454+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="camera"/><category scheme="http://www.blogger.com/atom/ns#" term="photo"/><title type='text'>Flickrのテスト</title><content type='html'>Flickrの写真を表示するテスト。&lt;br /&gt;
自宅の側で撮った月。&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://www.flickr.com/photos/siguremon/6648493801/&quot; style=&quot;font-size: 12px; line-height: 18px; margin-left: auto; margin-right: auto;&quot; title=&quot;P1140439 by siguremon, on Flickr&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;img alt=&quot;P1140439&quot; height=&quot;375&quot; src=&quot;http://farm8.staticflickr.com/7024/6648493801_8da86fc2e2.jpg&quot; width=&quot;500&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 18px;&quot;&gt;GF1 &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #fefefe; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: left;&quot;&gt;LUMIX G VARIO 45-200/F4.0-5.6　F5.6　1/200&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://siguremon.blogspot.com/feeds/3488584324813951386/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://siguremon.blogspot.com/2012/03/flickr.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1076369395379934366/posts/default/3488584324813951386'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1076369395379934366/posts/default/3488584324813951386'/><link rel='alternate' type='text/html' href='http://siguremon.blogspot.com/2012/03/flickr.html' title='Flickrのテスト'/><author><name>siguremon</name><uri>http://www.blogger.com/profile/05745965265092829532</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi155YeSvo2C4eIieq5bCMnLu1x3hG7MZEGAv6kwBEnRZNRQHJGnO6jsHB2FIb2NhwGQ9bV9RdIT0xMzVtF7txwLnmVyV6OgEpTO2vS4sXZn_wxryoJ-ivgziyYWlYdCw/s220/profile.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1076369395379934366.post-983078100686645935</id><published>2012-03-03T00:15:00.000+09:00</published><updated>2012-03-12T23:40:15.958+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="JUnit"/><title type='text'>JUnit入門―参考情報まとめ編</title><content type='html'>&lt;br /&gt;
最近お勉強中のJUnitについて、ちびちびとまとめていきます。&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;JUnitとは&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
JUnitとはJava用のユニットテストフレームワークです。&lt;br /&gt;
3.x系までと4.x系でテストクラスの書き方や実行の方法が異なっていて、&lt;br /&gt;
最新版は4.10です。（2012/3/2現在）&lt;br /&gt;
&lt;div&gt;
ビルドツール（AntやMavenなど）やIDEなどを始め、様々なツールが連携していて、&lt;/div&gt;
&lt;div&gt;
Java界隈ではデファクトスタンダードのようです。&lt;/div&gt;
&lt;br /&gt;
以下、参考情報まとめ。&lt;br /&gt;
&lt;br /&gt;
ところで、最新の機能について知りたい場合には、リリースノートかソースコードを見るしかないんでしょうか…&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;公式系&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
本家。最新情報等はこちらから。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.junit.org/&quot;&gt;http://www.junit.org/&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
レポジトリ。Githubにあります。jarなどのダウンロードもこちらから。&lt;br /&gt;
&lt;a href=&quot;https://github.com/KentBeck/junit&quot;&gt;https://github.com/KentBeck/junit&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
本家のスタートガイドなど。Junit Cookbookに一応簡単な例が載っています。&lt;br /&gt;
情報量はいまいちです。&lt;br /&gt;
&lt;a href=&quot;http://junit.sourceforge.net/&quot;&gt;http://junit.sourceforge.net/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;JUnit4系&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
4.x系でのテストクラスの要素についてまとめられています。&lt;br /&gt;
最初に読むのがおすすめです。&lt;br /&gt;
&lt;a href=&quot;http://d.hatena.ne.jp/oknknic/20111030/1319943307&quot;&gt;http://d.hatena.ne.jp/oknknic/20111030/1319943307&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
上記の要素について、より詳細な解説があります。&lt;br /&gt;
&lt;a href=&quot;http://www.ibm.com/developerworks/jp/java/library/j-junit4/&quot;&gt;http://www.ibm.com/developerworks/jp/java/library/j-junit4/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
4.x系から導入されたアサーションメソッド（assertThatとMatcher）の例がたくさん載っています。&lt;br /&gt;
モダンな書き方ならこちらでしょうか。&lt;br /&gt;
&lt;a href=&quot;http://d.hatena.ne.jp/daisuke-m/20090710/1247181113&quot;&gt;http://d.hatena.ne.jp/daisuke-m/20090710/1247181113&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;JUnit3系&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
3.x系について、インストールからテストクラスの書き方までまとめられています。&lt;br /&gt;
初心者向けな感じです。&lt;br /&gt;
&lt;a href=&quot;http://www.techscore.com/tech/Java/Others/JUnit/index/&quot;&gt;http://www.techscore.com/tech/Java/Others/JUnit/index/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3.x系でのJUnitの使い方から、JUnitを使ったTDDのサンプル、JUnitのTipsなどが書かれています。&lt;br /&gt;
3.x系がベースですが、今でもかなり参考になるんではないでしょうか。&lt;br /&gt;
長めなのでじっくり読む系です。&lt;br /&gt;
&lt;a href=&quot;http://www.javainthebox.net/publication/200401JP34/junit.html&quot;&gt;http://www.javainthebox.net/publication/200401JP34/junit.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
JUnit（3.x系）を使ったTDDの実況中継の記事「車窓からのTDD」です。（※pdf）&lt;br /&gt;
読み物系ですが、TDDのノウハウが詰まってます。&lt;br /&gt;
&lt;a href=&quot;http://objectclub.jp/technicaldoc/testing/stack_tdd.pdf&quot;&gt;http://objectclub.jp/technicaldoc/testing/stack_tdd.pdf&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;参考文献&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
「現場で使えるソフトウェアテスト Java編」&lt;br /&gt;
JUnit以外にも、テストで使える様々なツールについて解説されています。&lt;br /&gt;
さらには、テスト設計の技法も解説されていて、&lt;br /&gt;
Java系以外のテストエンジニアにもおすすめです。&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.co.jp/gp/product/4798114634/&quot;&gt;http://www.amazon.co.jp/gp/product/4798114634/&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
「テスト駆動開発入門」&lt;br /&gt;
JUnitの開発者Kent Beck氏によるTDDの入門書。&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.co.jp/gp/product/4894717115/&quot;&gt;http://www.amazon.co.jp/gp/product/4894717115/&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://siguremon.blogspot.com/feeds/983078100686645935/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://siguremon.blogspot.com/2012/03/junit.html#comment-form' title='1 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1076369395379934366/posts/default/983078100686645935'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1076369395379934366/posts/default/983078100686645935'/><link rel='alternate' type='text/html' href='http://siguremon.blogspot.com/2012/03/junit.html' title='JUnit入門―参考情報まとめ編'/><author><name>siguremon</name><uri>http://www.blogger.com/profile/05745965265092829532</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi155YeSvo2C4eIieq5bCMnLu1x3hG7MZEGAv6kwBEnRZNRQHJGnO6jsHB2FIb2NhwGQ9bV9RdIT0xMzVtF7txwLnmVyV6OgEpTO2vS4sXZn_wxryoJ-ivgziyYWlYdCw/s220/profile.jpg'/></author><thr:total>1</thr:total></entry></feed>