When setting up unit tests (in my case, using Jasmine for JavaScript) should the un-minified/in-uglified src
files be tested? Or should the end-user build
files (minified and uglified) be tested?
In my grunt config:
jasmine: {
src: ['src/file.js']
}
vs.
jasmine: {
src: ['build/file.min.js']
}
On one hand, it's nice to test the src
files since it doesn't remove debuggers and is easier to inspect when needed.
On the other hand, I can test the src
files as much as I like but it's not true to what the end users will be running, as the build
files are uglified and minified.
You should definitely unit test the bare source files as there were written. Unit tests are designed to be tightly focused and give you instant and clear feedback . In other words, if you test your functionality after the source code being modified - you are not testing your code in isolation; once you discover a bug, you cannot be 100% sure what caused it - it could be that there was a problem during the build that caused the problem - say the uglify
task.
I would classify testing build files as a part of integration or a higher-level testing - since aside from testing functionality, you are also checking how your application was built: how the files were minified, copied, concatenated etc.
In general, you should aim to the following pyramid:
( introduced in this Google Test Automation blogpost )
On the other hand, I can test the src files as much as I like but it's not true to what the end users will be running, as the build files are uglified and minified.
I think this goes under the End-to-end testing category - imitating a real user, going through acceptance-testing scenarios, user stories.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.