如何执行测试的实施?

How to perform the implementation of tests?

我目前有一个应用程序,我的后端在 PHP (Codeigniter) 中,前端在 Vuejs 中。我知道测试文化对于保证一个软件的质量是超级重要的,但是我对如何入手有很多疑惑:

Where do I start? Do I write the tests for the backend or frontend first?

Before deploying the application, should I run all tests? Backend and frontend?

I know that there are test frameworks for PHP (PHPUnit) and for Vue as well (Jest) I wonder if there is any way to test the styling part, too, of CSS. Because sometimes i often create a class in my style sheet that breaks some other element of the application.

这取决于你,在完美的世界中你应该也测试 BE 和 FE。

这很棘手,因为测试 BE 是必不可少的,因为你所有的业务逻辑都在那里,它可能会导致安全问题。

FE 测试对于您的用户/客户来说可能更重要一些,因为他们只会看到那个结果,但是如果您有一个闪亮的 FE,但您的 BE 有很多问题,您的客户会感到沮丧。

我认为如果您没有足够的资源或测试团队,您可以通过 API 测试您的 BE,因为这就是您的 Vue FE 与您的 PHP 通信的方式,而且更容易覆盖您的功能比编写单元测试所有 PHP 代码。

无论如何你提到 sometimes i often create a class in my style sheet that breaks some other element of the application. 如果你在你的组件中使用 scoped 风格它就不再是问题了:

https://vue-loader.vuejs.org/guide/scoped-css.html