开发者

Is it a good idea to run unit tests of a library as part of the MSI that installs it?

开发者 https://www.devze.com 2022-12-11 12:59 出处:网络
I have a system that has many components interacting with each other. It occured 开发者_运维知识库to me to run tests as part of the installation process to make sure it works correctly in the client m

I have a system that has many components interacting with each other. It occured 开发者_运维知识库to me to run tests as part of the installation process to make sure it works correctly in the client machine.

Does this sound like a reasonable idea? Have you seen it done? What framework would you use to run the tests?


Unit tests (ideally) should be environmentally independent, so I don't think you would want to run unit tests after software installation. However, you should run system verification tests, which verify that the environmental conditions required by your software exist. Common examples of environmental conditions are: availability of web services, proper file access permissions, and availability of network access.


I don't think that you'd want to run your entire suite of unit tests. Depending on how large the application and how large the suite of tests, this may become a very expensive part of the installation process. Also, unit tests should functional blocks in isolation, independent of their environment.

What might be more valuable is a collection of tests, packaged as a stand-alone program, that specifically target the aspects of the installation that may be problematic. For example, making sure that registry keys were written to the expected location on a 32-bit vs. 64-bit machine or that a temporary file area is readable/writable.


Doing some kind of post-install testing to check the install status seems like a very reasonable thing to do. Whether you call it or treat it like unit testing might confuse the subject. Unless of course your are installing 3rd part components for developers and you want to test the build.


Some sort of validation that the install was successful and that the necessary components are available makes sense. But I'm thinking you might be barking up the wrong tree with unit tests.

Unit tests are to make sure code still works after part of the system has been altered. You might could twist a unit testing framework to accomplish what you need, but not being its primary mission, you might run into unexpected problems.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号