Skip to content

Instantly share code, notes, and snippets.

@kyonmm
kyonmm / HogeSpec.groovy
Last active December 22, 2015 15:39
Spockテンプレ。 curl -s get.gvmtool.net | bash でインストール。gvm install gradle.  projectディレクトリをつくって、そこにbuild.gradleをコピーして、gradle --daemon idea. open hoge.ipr. src/main/groovyとsrc/test/groovyを作成してsourceとtestとして指定する。あとは書く。 importとかの自動生成は赤線に合わせてAlt + Enterだった気がする。
import org.spock.*
class HogeSpec extends Specification {
@Unroll
def "sample #a #b #expected "(){
given:
println "$a $b $ expected"
when:
println "$a $b $ expected"
then:
#############################################################
################### OFFICIAL UBUNTU REPOS ###################
#############################################################
###### Ubuntu Main Repos
deb http://jp.archive.ubuntu.com/ubuntu/ precise main restricted universe
deb-src http://jp.archive.ubuntu.com/ubuntu/ precise main restricted universe
###### Ubuntu Update Repos
deb http://jp.archive.ubuntu.com/ubuntu/ precise-security main restricted universe
@kyonmm
kyonmm / jggug-junit-groovy-summary.md
Last active January 4, 2016 21:19 — forked from anonymous/jggug-junit-groovy-summary.md
2/21(金)のG* ワークショップZ でのハンズオン概要

JUnit4を利用したテスティングフレームワーク開発

自己紹介

  • kyon_mm
  • 名古屋市内企業に勤務しているテストアーキテクト
  • CI, DVCS, ITSなどの開発環境サポート、テスト戦略策定、テスト自動化などがメイン業務
  • .NETアプリに対してGroovy, C#, F#, Scalaなどでテストコードを実装することが多い
  • SCMBootCamp, Nagoya.Testing, 基礎勉強会などを主催

開催概要

GroovyにはSpockというCoolなテスティングフレームワークが存在しますが、特定チームに最適であるかはまた別の話になります。今回はJUnit4のAPIを使ってオリジナルのテスティングフレームワークを作るハンズオンを行います。基本的にはxUnitでテストコードを書いたことがあり、JavaもしくはGroovyの基本文法を理解していれば大丈夫です。

println "hello! install from gru"
def OPENING = [
"「ソフトウェアテストのレトロスペクティブ」kyon_mm",
"「皆さんが聞きたいkyon_mmのこと、私が答えます!」kaori_t_spica",
"「アンケートで書いてくれた質問に答えます!」kyon_mm",
"「Groovy(G*)によるSIer閉鎖空間サバイバル術」nobusue",
]
def MASAKARIST = [
"「F# のコンピュテーション式かモナド」 pocketberserker",
"「型とは何か? - CPythonの実装」cocoatomo",
  1. 「ソフトウェアテストのレトロスペクティブ」kyon_mm
  2. 「皆さんが聞きたいkyon_mmのこと、私が答えます!」kaori_t_spica
  3. 「アンケートで書いてくれた質問に答えます!」kyon_mm
  4. 「Groovy(G*)によるSIer閉鎖空間サバイバル術」nobusue
  5. 「型とは何か? - CPythonの実装」cocoatomo
  6. 「mercurialとbazaarとpythonメタプログラミング(狩)」wonderful_panda
  7. 「テストの戦略や計画を支えるマサカリ抑止力(狩)」goyoki
  8. 「F# のinlineと型推論(狩)」gab_km
  9. 「F# のコンピュテーション式かモナド」 pocketberserker
  10. 「Scalaの楽しさ(狩)」kmizu
// 実装が透けている例 : 避けたい
def sut = new User()
def fooGame = new FooGame()
sut.touch(fooGame.icon)
// 要求分析や定義に使えそうな例 : 使いたい
def A_user = new User()
def installedFooGame = new FooGame()
A_user.touch(installedFooGame.icon)

テストの使い方

JaSST Tohoku 2014

2014/05/23

kyon_mm

自己紹介

  • きょん(@kyon_mm) 26歳 ゆとり世代
  • なごや で テストの仕事しています
@kyonmm
kyonmm / sample.groovy
Created August 11, 2014 08:48
DCIかどうか知らんが、おれが書きたいのはこういうのをもうちょっときれいに書くことだ。
import groovy.transform.TupleConstructor
Object.metaClass.addRole = {role ->
delegate.metaClass.mixin role
}
@TupleConstructor
class InFrontOfWoman {
def he
InFrontOfWoman(コミュ障 people){
using (SqlTransaction transaction = connection.BeginTransaction())
{
try
{
// 処理
transaction.Commit();
}
catch
{
if(MyRollback(transaction) == false){