Upgrade to Pro — share decks privately, control downloads, hide ads and more …

testharness.js を使ってみた。

testharness.js を使ってみた。

testharness.js の解説と、具体的なテストの記述例です。

Avatar for Yuki Sekiguchi

Yuki Sekiguchi

April 11, 2014

Other Decks in Programming

Transcript

  1. About Me Yuki Sekiguchi / Twitter: @yukiseki712 Software Engineer NetFront

    Browser NetFront Life Browser NetFront Browser NX for Wii U PUBLUS Reader Chromium(20) / WebKit(13)
  2. template(script) <script> test(function() { [body of test function - must

    include at least one assert*() function] }, [Test Name]); </script>
  3. assert? これは、(true / false / XXXと等しい / XXX と等しく ない)

    べきだ! assert_something(確かめる値: actual, 期待する 値: expected, 何を確かめてるのかの説明: description)
  4. insertBefore test(function() { var parent = document.getElementById("parent"); var before =

    document.getElementById("before"); var child = document.createElement("div"); parent.insertBefore(child, before); assert_equals(child.parentNode, parent, "There should be the element under the parent element."); assert_equals(child.nextSibling, before, "There should be the element at the previous of the before element."); }, "Insert before the before element.");
  5. window.document readonly attribute Document document; test(function() { assert_own_property(window, "document", "The

    window object should have document attribute."); assert_readonly(window, "document", "The document attribute should read only."); }, "Checks document attribute of window object.");
  6. Ruby <ruby><span id="base">漢字</span><rt id="text">かんじ</ruby> test(function() { var base = document.getElementById("base");

    var text = document.getElementById("text"); assert_equals(base.getBoundingClientRect().left, text.getBoundingClientRect(). left, "Ruby base and ruby text should create one ruby pair."); }, "Ruby base and ruby text creates one ruby pair.");
  7. Q&A