|
Post by Mitu46544 on Nov 9, 2023 1:41:50 GMT -4
整个首先在名为的同一目录中创建一个新文件复制注意组织测试的方法有很多种。在本系列中测试将写入测试目标旁边的文件中也称为托管测试。如果您使用并拥有或更高版本您可以使用一项很酷的功能该功能可以在并置测试及其目标时清理项目的文件树。在中前往屏幕顶部选项栏中的代码首选项设置。在设置页面中通过键入来搜索文件嵌套设置。启用以下设置中的文件嵌套选项接下来在这些设置中进一步向下滚动您将看到。 部分如果名为的项目不 马来西亚电话号码表 存在请创建一个。然后将项的值更新为中的文件嵌套设置这使得可以将任何文件嵌套在名为为了更好地说明请参见以下示例嵌套文件在上面你可以看到一个名为嵌套在该文件下的是虽然不是绝对必要的但在托管单元测试时此设置可能有助于清理文件树。导入所需模块在新文件的顶部您需要导入一些允许您编写测试的内容复制以下是每个导入的用途这是您正在编写测试的服务。 您需要导入它才能调用它的函数。这是在提供的的模拟版本。函数内使用的库来生成随机颜色。它提供的函数允许您描述一组测试。需要注意的是导入。这是模拟的客户端实例它允许您执行查询而无需实际访问数据库。因为它是模拟的所以您还可以操纵查询响应并监视其方法。您可能想知道上面的测试如何能够检查调用了多少次。请记住在此文件的上下文中模块被模拟并且其默认导出被配置为提供返回静态字符串值的函数。
|
|