xUnit??????????????
?????ntop ???????[ 2017/6/6 15:15:58 ] ?????????????????? ???????
??????????? Philosophy of Test Automation ???????????????????????????????ν “???” ????????????????????????????????????????Щ???????????Щ?????????????д????????????????????????????????????????а?????
???????????????????????????????Щ?????????
????· “Test after” versus “test first”
????· Test-by-test versus test all-at-once
????· “Outside-in” versus “inside-out”
????· Behavior verification versus state verification
????· “Fixture designed test-by-test” versus “big fixture design upfront”
???????“Outside-in” versus “inside-out” (applies independently to design and coding)
????Test First or Last
????????д??????????д??????????????????????????д?????????????????Щ??????????????????????????????飬??????????????????д??????????ν??TDD?????????е?????????????????????е?????????????????????????????????????п???????????(“design for testability”)????????????????????ò?????????С?
???????????д??????????????????????????????????o?д?????????????????????????????????Щ???????????????????????????С???????????TDD?????д?????????????????????????????????????????????????????????????????????????????????????????????TDD??????...????
???????????????????????????????????????????????????????????????????????????????????????????? System.currentTimeMillis()??????????????????????????????????????????????????? equals() ??????
????Tests or Examples
??????TDD?У?????д?μ??????????????????????????????????????“TDD”????????????????????????????????????????????????д?????????????????仰?????е??????????Test??????Example????????????????????ν???????????д?ЩExample????ЩExample?????е???????????????ЩExample??????????????????????
???????????????????????????? TDD ?? Example Driven DevelopmentD ?? EDD??????????????????????TDD?????????????????EDD???????? Ruby ?? RSpec ???? ????Java ?? JBehave?????EDD??TDD??????????????????????????????????????????? “Executable Specification”??
????Test-by-Test or Test All-at-Once
????????????????“д????????д??????”???????д?????е??????????????????????TDD???? “write a test” ??? “write some code” ??????????????????????????д????????д?????е?????????????д???????????????????????????????????????????????????
????“Test a bit?? code a bit?? test a bit more”
??????????????????д?????????????в?????????????????????? “think like a client” ???? “think like a tester” ?????????????絽 “solution mode” ??TDD????????????????????????????λ????????δ????????2?????????????????????????????????
????????????????????????????Э???????????????????????д?????е???????????????????????????????????????????????
????Outside-In or Inside-Out
????????????????????????????????“??????”????“???????”????????????????????????????????“???”????????????????????????????????????????????У??????????“???????”??“???????”????????????????????????????????????δ??????????????????????????????д????????????????????????A??B??C??A????B??B????C??????????????C???????B???????A????????????????????????
???????????????????μ????????????A?????B??C???????????У????????????????????????????????????? TestStubs ???? Mock Objects ???????????????????????????????????????????????????Щ?????????
????State or Behavior Verification
???????????????????????????????????????????????????????SUT???????????????????????????????????????????????????????????SUT???Щgetter?????????????????????????????????????????????????????????????????????????????????????ò???????????????????п???????з?????????????????????????????????????ЩMock??????????
??????????????BDD - Behavior Driven Development???????????????????????? Mock Object ?? Test Spies?????????????????????????????????????????????????????????????????????????????????????????Mock??????????????????????????
???????????о???????????????????????????????????????ο????????
????Fixture Design Upfront or Test-by-Test
?????????д???????Fixture??????????????Fixture???
??????????????????У????? “Test Bed” ???????????ú????????????????л????д??????????????????????????????????xUnit??Fixture???????????????????????????TestCase????????????Fixture?ü???TestCase??????????????TestCase?????????Fixture???????Fixture?????????setup??????????????????????в???????????У?????????????????е???????????????μ?Fixture??
???????????????????????????????ж????TestCase?????????????????Fixture?е???Щ??????????????????????????????????????????С??Texture??????????????????Щ??
?????????????????η??? Test Fixture????й???????????????Щ???????????Щ??????????????????????????Fixture???????о?/???????????????????????????????????????????
????????
????????????в??????????????????????????????????????????????????CodeReview????ж?????????????????????????????if-else?????????????????и?????????????????????????????????????????е??????????????(xUnit Test Pattern????????)???????????????????????????????????????????????
????· Write the tests first!
????· Tests are examples!
????· I usually write tests one at a time?? but sometimes I list all the tests I can think of as skeletons upfront.
????· Outside-in development helps clarify which tests are needed for the next layer inward.
????· I use primarily State Verification but will resort to Behavior Verification when needed to get good code coverage.
????· I perform fixture design on a test-by-test basis.
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11