Most of the tests that currently cover core functionalities depend heavily on (and sometimes test) internal implementation characteristics. While they should be testing whether given implementation produces desired outcome (treating its implementation more as a black box).
Current state of things is problematic for eventual internal improvements and refactors which occasionally we want to introduce, as in most of such cases proposed improvements need to be accompanied with counterproductive numerous updates to tests which are covering otherwise not altered functionalities .
At some point we've introduced a new (black box based) way of testing the internals. It's through runServerless utlity, which allows us create natural (as in real world) serverless instance, and inspect the produced outcome for chosen command. More details here: https://github.com/serverless/serverless/tree/master/test#unit-tests
Most of the tests that currently cover core functionalities depend heavily on (and sometimes test) internal implementation characteristics. While they should be testing whether given implementation produces desired outcome (treating its implementation more as a black box).
Current state of things is problematic for eventual internal improvements and refactors which occasionally we want to introduce, as in most of such cases proposed improvements need to be accompanied with counterproductive numerous updates to tests which are covering otherwise not altered functionalities .
At some point we've introduced a new (black box based) way of testing the internals. It's through
runServerlessutlity, which allows us create natural (as in real world)serverlessinstance, and inspect the produced outcome for chosen command. More details here: https://github.com/serverless/serverless/tree/master/test#unit-testsThis is issue is about refactoring lib/plugins/aws/package/compile/events/cloudFront/index.test.js to
runServerlessbased variant.It's needed, so we cleanly move forward with #8502
To make refactor relatively easy:
serverless/lib/plugins/aws/package/compile/events/cloudFront/index.test.js
Line 1632 in 4b3c355
runServerlessruns are expected to happen, against which fixture and command they should be basedFor every refactored test, the old test should be removed
Refactor can be submitted with one PR, but partial refactors that cover some of below listed parts are also very welcome:
serverless/lib/plugins/aws/package/compile/events/cloudFront/index.test.js
Lines 1633 to 1657 in 4b3c355
serverless/lib/plugins/aws/package/compile/events/cloudFront/index.test.js
Lines 1659 to 1742 in 4b3c355
serverless/lib/plugins/aws/package/compile/events/cloudFront/index.test.js
Lines 1808 to 1836 in 4b3c355
serverless/lib/plugins/aws/package/compile/events/cloudFront/index.test.js
Lines 1949 to 2010 in 4b3c355
The text was updated successfully, but these errors were encountered: