自動軟體測試、TDD 與 BDD

Yuren Ju
Yuren Ju
Jul 5, 2017 · 9 min read
https://github.com/yurenju/laborrights/commits/master
https://travis-ci.org/yurenju/laborrights/builds/249925132

TDD (Test-Driven Development)

// 一個月薪 25000 男性,今天剛上班的勞工,在平常日從八點工作十一個小時
// 他的加班費應該為 451 元
const labor = new Labor()
labor.setAge(20)
.setGender(Gender.MALE)
.onBoard(new Date())
.setMonthlySalary(25000)
const worktime = new WorkTime(Duration.DAY, labor)
const start = new Date(2017, 6, 5, 8)
worktime.add(start, 11)
const result = worktime.overtimePay()
expect(result.value.overtimePay).eq(451)

BDD (Behavior-driven development)

https://github.com/yurenju/laborrights/blob/master/features/contact.feature
https://github.com/yurenju/laborrights/blob/master/features/step_definitions/common-steps.js

Yuren Ju

Written by

Yuren Ju

旅行、咖啡、科技宅

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade