我编写调用我的 dal 代码的测试,并在检查插入/更新/删除是否实际发生后,即所谓的状态测试。 这些是 pr 定义,不是单元测试,而是集成测试,但它们实际上帮助我多次进行数据库更改。 随着时间的推移,我进行了更多更好的测试,甚至更大的数据库更改也进展得相当顺利。
I write tests that call my dal code and after I check if the inserts/updates/deletes actually occurred, so called state tests. These are pr definition not Units test but rather integration tests, but they have actually helped me many times doing database changes. Over the time I have more and better tests and even bigger database changes go rather seamlessly.
The concept of having tests, according to TDD, is that you test the way things are meant to work now. When you need to change something, you change the tests that address that, (ensure the current codebase fails), and then make the code changes until the tests pass. The tests that didn't change give you confidence that other aspects of your software is still doing what it used to and that your refactoring hasn't broken anything.
So you don't write tests with refactoring in mind; rather, you test your requirements, and then when your requirements change you update the tests accordingly, and refactor the code so it passes the new tests.
Always fear every change you make to a database. This will compel you to double check every thing you change and narrow down the possible errors.
Keep in mind that databases are usually the backbone of one or more application, so every change you make must be planned carefully and properly tested.
发布评论
评论(4)
我编写调用我的 dal 代码的测试,并在检查插入/更新/删除是否实际发生后,即所谓的状态测试。 这些是 pr 定义,不是单元测试,而是集成测试,但它们实际上帮助我多次进行数据库更改。 随着时间的推移,我进行了更多更好的测试,甚至更大的数据库更改也进展得相当顺利。
I write tests that call my dal code and after I check if the inserts/updates/deletes actually occurred, so called state tests. These are pr definition not Units test but rather integration tests, but they have actually helped me many times doing database changes. Over the time I have more and better tests and even bigger database changes go rather seamlessly.
根据 TDD 的说法,进行测试的概念是测试事物现在的工作方式。 当您需要更改某些内容时,您可以更改解决该问题的测试(确保当前代码库失败),然后更改代码直到测试通过。 没有改变的测试让您确信软件的其他方面仍然按照以前的方式进行,并且您的重构没有破坏任何东西。
因此,您在编写测试时不会考虑重构;而是会考虑重构。 相反,您测试您的需求,然后当您的需求发生变化时,您相应地更新测试,并重构代码,以便它通过新的测试。
The concept of having tests, according to TDD, is that you test the way things are meant to work now. When you need to change something, you change the tests that address that, (ensure the current codebase fails), and then make the code changes until the tests pass. The tests that didn't change give you confidence that other aspects of your software is still doing what it used to and that your refactoring hasn't broken anything.
So you don't write tests with refactoring in mind; rather, you test your requirements, and then when your requirements change you update the tests accordingly, and refactor the code so it passes the new tests.
始终担心对数据库所做的每一个更改。 这将迫使您仔细检查您更改的所有内容并缩小可能的错误范围。
请记住,数据库通常是一个或多个应用程序的支柱,因此您所做的每一项更改都必须仔细计划并正确测试。
Always fear every change you make to a database. This will compel you to double check every thing you change and narrow down the possible errors.
Keep in mind that databases are usually the backbone of one or more application, so every change you make must be planned carefully and properly tested.
在编写存储过程时,我会随意添加调试/打印语句。 使用 @Debug 作为 bit 类型的输入参数:
When writing stored procedures, I liberally add Debug / Print statements. With @Debug as a input parameter of type bit :