Created
April 21, 2013 14:21
-
-
Save shinofara/5429761 to your computer and use it in GitHub Desktop.
javascriptの自動テスト化して楽をする!(まだβ版のjasmine-standalone-2.0.0を使ってるよ)導入編 ref: http://qiita.com/items/f1ad4e9331a11be20d66
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /usr/loca/src/ | |
git clone git://github.com/pivotal/jasmine.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd テスト用ディレクトリ(どこでもOK) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo cp /usr/local/src/jasmine/dist/jasmine-standalone-2.0.0-alpha.zip ./ | |
unzip jasmine-standalone-2.0.0-alpha.zip -d jasmine |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jasmine | |
|- SpecRunner.html ・・・テストページ | |
|- lib ・・・jasmineライブラリ | |
|- spec ・・・テストケース | |
|- src ・・・テスト用ソース |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby -rwebrick -e 's = WEBrick::HTTPServer.new(:Port=>39999, :DocumentRoot=>Dir.pwd, :CGIInterpreter=>"/usr/local/bin/ruby -Eutf-8:utf-8");trap("INT"){s.shutdown};s.start' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby -rwebrick -e 's = WEBrick::HTTPServer.new(:Port=>39999, :DocumentRoot=>Dir.pwd, :CGIInterpreter=>"/usr/local/bin/ruby -Eutf-8:utf-8");trap("INT"){s.shutdown};s.start' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<title>Jasmine Spec Runner v2.0.0-alpha</title> | |
<link rel="shortcut icon" type="image/png" href="lib/jasmine-2.0.0-alpha/jasmine_favicon.png"> | |
<link rel="stylesheet" type="text/css" href="lib/jasmine-2.0.0-alpha/jasmine.css"> | |
<script type="text/javascript" src="lib/jasmine-2.0.0-alpha/jasmine.js"></script> | |
<script type="text/javascript" src="lib/jasmine-2.0.0-alpha/jasmine-html.js"></script> | |
<script type="text/javascript" src="lib/jasmine-2.0.0-alpha/boot.js"></script> | |
<!-- include source files here... --> | |
<!-- | |
<script type="text/javascript" src="src/Player.js"></script> | |
<script type="text/javascript" src="src/Song.js"></script> | |
--> | |
<!-- include spec files here... --> | |
<!-- | |
<script type="text/javascript" src="spec/SpecHelper.js"></script> | |
<script type="text/javascript" src="spec/PlayerSpec.js"></script> | |
--> | |
<script type="text/javascript" src="spec/test.js"></script> | |
<script type="text/javascript"> | |
(function() { | |
var jasmineEnv = jasmine.getEnv(); | |
jasmineEnv.updateInterval = 1000; | |
var htmlReporter = new jasmine.HtmlReporter(); | |
jasmineEnv.addReporter(htmlReporter); | |
jasmineEnv.specFilter = function(spec) { | |
return htmlReporter.specFilter(spec); | |
}; | |
var currentWindowOnload = window.onload; | |
window.onload = function() { | |
if (currentWindowOnload) { | |
currentWindowOnload(); | |
} | |
execJasmine(); | |
}; | |
function execJasmine() { | |
jasmineEnv.execute(); | |
} | |
})(); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("Player", function() { | |
var aa; | |
//事前処理 | |
beforeEach(function() { | |
aa = '123'; | |
}); | |
//テストケース | |
it("A処理のバリデーションチェック", function() { | |
if (123 !== aa) { | |
//例外が上がればエラー | |
throw new Error("int型ではない為エラー"); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment