neraliu's blog internet profession in between hongkong/china and silicon valley (no longer, but the world!)

307月/090

working on the unit test with external systems

yes, writing unit test for the library or some key components in the system is extremely important for the substain-ability of the piece of software, this is not only for the software itself, but also for the technologt companies, you cannot guarantee your staff staying in the team all the time, especially those talents. as the software architect, you have to make sure the maintenance of the software still going on even though your staffing change (leave your company etc.)

in writing the test code looks simple, as the basic rationale is to test your function with some cases, however, it is inevitable to have some dependency on the external systems with your library or component, for example, the database connection etc. and for the good test suite, the ideal case is, once you checkout from the source code repository, initialize an isolated environment, build the code, and then the test cases can be run to verify the code correctness. however, hose external systems makes thing complicated to be happened.

in order to address this, the concept of "stub" or "mock" object is introduced in the unit test development, in general, it is the methodology of emulating the function implementation in your library which requires external dependency, making the ideal situation mentioned above happens.

by the way, unit test is just the beginning of the software testing in the industry.

存檔在: 科技, 電腦 沒有回應