用意されているテスト● Unit Tests –Junitで各クラスを● Functional Tests – Junit + HttpClient でコントローラを叩いて● Selenium Test – ビルトインされたSelenium で受け入れテスト
14.
Unit Testimport play.test.*;importorg.junit.*;public class MyTest extends UnitTest { @Test public void aTest() { assertEquals(2, 1 + 1); // A really important thing to test } @Test public void testUsers() { assertEquals(3, Users.count()); }}
Selenium Test#{selenium 'Testsecurity'} // Try to log in the administration area clearSession() open('/admin') assertTextPresent('Login') type('login', 'admin') type('password', 'secret') clickAndWait('signin') // Verify that the user in correctly logged in assertText('success', 'Welcom admin!')#{/selenium}※直接HTMLテーブルを書く方法でもできます
ご心配なく● 下記コマンドがあります $ play auto-test● 内部でHtmlUnitを使っています● 先程のTestsRunnerをバックグラウンドで走らせる ことが出来ます● これでJenkinsで自動ビルド&テストが可能です
33.
HtmlUnitとは● HtmlUnit is a "GUI-Less browser for Java programs". It models HTML documents and provides an API that allows you to invoke pages, fll out forms, click links, etc... just like you do in your "normal" browser. (http://htmlunit.sourceforge.net/)● Jenkins内部のHudsonTestCaseの中にも組み込ま れてますよね