You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
testtime package provides testtime.Now() and testtime.SetTime(). testtime.SetTime() stores a fixed time to a map with goroutine ID of testtime.SetTime() as a key. When goroutine ID of testtime.Now() is related to a fixed time by testtime.SetTime(), it returns the fixed time otherwise it returns current time which is returned by time.Now(). package main import ( "fmt" "time" "testing" "github.com/t
Project status Please see the release notes page. Updates are announced via Twitter Follow @mockitojava and mailing list . Mockito downloads and instructions for setting up Maven, Gradle and other build systems are available from the Central Repository. The documentation for all versions is available on javadoc.io (the site is updated within 24 hours of the latest release). Still on Mockito 1.x? S
golangでテストのためだけにinterfaceを書くのが死ぬほど嫌だったので編み出した技を紹介します。 TL;DR テスト(=mock)のためだけにinterfaceは切りたくない 型エイリアスとビルドタグを組み合わせるとinterfaceがなくてもモックが作れる この手法に必要なモックを自動生成するプログラムを作った interfaceは本当に必要なシーンで使うべき Background 現在モックを使った単体テストは一般的です。 Javaでの例を挙げると、モックしたいコンポーネントについて予めinterfaceを定義しておき、モックではそのインターフェースを実装するのが定石です。 しかしgolangのinterfaceはJavaなどのそれとは若干性質が異なるため、テスト=モックのためだけにinterfaceを書くのはオーバーワーク気味です。 そうテストのためだけにinterface
はじめまして!4/1よりSWETに加わった@Kuniwakです。 今回は、私がSWETに入って驚いたことと、そしてSWETだからこそ生まれたものについてお話しします。 まずKuniwakはどんな人? 開発を高速化させるテストや静的検査を生業としています。主に、以下のような記事やスライドを書いています。 テストがなかった無法地帯にテストを導入して開発速度を1.7倍にした話 iOS開発を効率化するテストのデザインパターンについて Swiftの HTTPライブラリで苦しまないための自作APIクライアント設計 ※TDD(テスト駆動開発)という言葉を使わないでTDDを実践している記事 Vim script静的解析の光と闇 では、こんな私がSWETという自動テストのエキスパートのチームで働くことになって驚いたことを紹介します。 SWETに入って驚いたこと SWETに入って驚いたのは、テストに関連するト
At Tapjoy we have a team that focuses on optimizing our infrastructure. We've identified areas in our infrastructure that can be rewritten to reduce our cloud expenses as well as prepare our infrastructure to scale up to handle our traffic growth. To this end we're employing more and more Go because it's a strongly typed compiled language that is easy to learn and gives performance benefits right
こんにちは、小野マトペです。タイトル全部です。 昨日、現在時刻によって条件分岐するロジックを含むGoプログラムを書いていて、どうテストするか困ったのですが、うまい(と思う)やり方を思いついたのでここに書いておきます。 書いていたのはまあだいたいこういうソースコードです。 // main.go package main import ( "fmt" "time" ) func main() { fmt.Println(Greet("マトペ")) } func Greet(n string) string { t := time.Now() if 6 <= t.Hour() && t.Hour() <= 18 { return fmt.Sprintf("こんにちは%sさん。今は%d時ですよ!", n, t.Hour()) } else { return fmt.Sprintf("こんばんは%s
Goで net/http を使ったControllerのテストには、 net/http/httptest モジュールを使うと擬似的にサーバをその場で立て、登録したハンドラにリクエストを送れます。 ただ、APIに使うアクションはたびたび、外部のAPIを叩くこともあります。 その際、テストを実行するときに外部APIを使えない状況(本番環境とは違う状況、例えば、production用のAPIの発行には金銭が発生するなど)に遭遇します。 そんなときに知られているテクニックとして、テスト時に外部APIへのリクエストをDouble(Stub)することです。 その外部APIが返却するであろう期待値を登録しておけば正常ケースを、エラー値を登録しておけばエラーケースをテストできます。 ここで例に挙げるStubする方法は、 http.Client をもとにHTTPリクエストすることを前提としています。 ではど
About That's what Mocker is about: Graceful platform for test doubles in Python (mocks, stubs, fakes, and dummies). Inspiration from real needs, and also from pmock, jmock, pymock, easymock, etc. Expectation of expressions defined by actually using mock objects. Expressions may be replayed in any order by default, Trivial specification of ordering between expressions when wanted. Nice parameter ma
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く