7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

jasmine導入方法(個人用)

Last updated at Posted at 2015-05-01

JavaScript 用のテスティングフレームワークである Jasmine の使い方のメモ。個人用備忘録。
eclipseへの導入方法。

ダウンロード

https://github.com/jasmine/jasmine
→「Download ZIP」
→ すべて展開

必要なライブラリ 4つ
 ・jasmine.js
 ・jasmine-html.js
 ・boot.js
 ・jasmine.css
 (・jasmine_favicon.png) ←ファビコン用

コーディング

sample.html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    
    <script src="jasmine.js"></script>
    <script src="jasmine-html.js"></script>
    <script src="boot.js"></script>
    <link rel="stylesheet" href="jasmine.css" />
    <link rel="shortcut icon" type="image/png" href="jasmine_favicon.png" />
    
    <script src="app.js"></script>
    <script src="app-test.js"></script>
  </head>
  <body>
  </body>
</html>
app.js
function add(a, b) {
    return a + b;
}
app-test.js
describe('add 関数のテスト', function() {
    it('1 + 1 は 2', function() {
        expect(add(1, 1)).toBe(2);
    });
  
    it('1 + 4 は 5', function() {
        expect(add(1, 4)).toBe(5);
    });
  
    it('10 + 2 は 12', function() {
        expect(add(10, 2)).toBe(5); // わざと失敗させている
    });
});

配置
キャプチャ.JPG

表示

jasmine.JPG

jasmine.JPG


参照 http://qiita.com/opengl-8080/items/cf3acafda9756f4b04c9
7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?