草庐IT

translation-unit

全部标签

unit-testing - 如何使用 Go 中的测试包进行测试设置

当使用testingpackage时,如何进行整体测试设置处理,为所有测试奠定基础?例如,在Nunit中有一个[SetUp]属性。[TestFixture]publicclassSuccessTests{[SetUp]publicvoidInit(){/*Loadtestdata*/}} 最佳答案 从Go1.4开始,您可以实现setup/teardown(无需在每次测试之前/之后复制您的函数)。文档概述here在主要部分:TestMainrunsinthemaingoroutineandcandowhateversetupandte

unit-testing - 在 Go 中分离单元测试和集成测试

在GoLang(作证)中分离单元测试和集成测试是否有既定的最佳实践?我混合了单元测试(不依赖任何外部资源,因此运行速度非常快)和集成测试(确实依赖任何外部资源,因此运行速度较慢)。所以,当我说gotest时,我希望能够控制是否包含集成测试。最直接的技术似乎是在main中定义一个-integrate标志:varrunIntegrationTests=flag.Bool("integration",false,"Runtheintegrationtests(inadditiontotheunittests)")然后在每个集成测试的顶部添加一个if语句:if!*runIntegrationT

unit-testing - 在 Go 中分离单元测试和集成测试

在GoLang(作证)中分离单元测试和集成测试是否有既定的最佳实践?我混合了单元测试(不依赖任何外部资源,因此运行速度非常快)和集成测试(确实依赖任何外部资源,因此运行速度较慢)。所以,当我说gotest时,我希望能够控制是否包含集成测试。最直接的技术似乎是在main中定义一个-integrate标志:varrunIntegrationTests=flag.Bool("integration",false,"Runtheintegrationtests(inadditiontotheunittests)")然后在每个集成测试的顶部添加一个if语句:if!*runIntegrationT

unit-testing - 使用 Go 语言进行测试的正确包命名

我在Go中看到了几种不同的测试包命名策略,想知道每种方法的优缺点以及我应该使用哪一种。策略1:文件名:github.com/user/myfunc.gopackagemyfunc测试文件名:github.com/user/myfunc_test.gopackagemyfunc见bzip2举个例子。策略2:文件名:github.com/user/myfunc.gopackagemyfunc测试文件名:github.com/user/myfunc_test.gopackagemyfunc_testimport("github.com/user/myfunc")见wire举个例子。策略3:文

unit-testing - 使用 Go 语言进行测试的正确包命名

我在Go中看到了几种不同的测试包命名策略,想知道每种方法的优缺点以及我应该使用哪一种。策略1:文件名:github.com/user/myfunc.gopackagemyfunc测试文件名:github.com/user/myfunc_test.gopackagemyfunc见bzip2举个例子。策略2:文件名:github.com/user/myfunc.gopackagemyfunc测试文件名:github.com/user/myfunc_test.gopackagemyfunc_testimport("github.com/user/myfunc")见wire举个例子。策略3:文

unit-testing - 如何在 Go 中测量测试覆盖率

有没有人成功地为Go单元测试生成代码覆盖率?我在网上找不到这样的工具。 最佳答案 请注意Go1.2(Q42013,rc1isavailable)现在将显示testcoverageresults:Onemajornewfeatureofgotestisthatitcannowcomputeand,withhelpfromanew,separatelyinstalled"gotoolcover"program,displaytestcoverageresults.Thecovertoolispartofthego.toolssubrep

unit-testing - 如何在 Go 中测量测试覆盖率

有没有人成功地为Go单元测试生成代码覆盖率?我在网上找不到这样的工具。 最佳答案 请注意Go1.2(Q42013,rc1isavailable)现在将显示testcoverageresults:Onemajornewfeatureofgotestisthatitcannowcomputeand,withhelpfromanew,separatelyinstalled"gotoolcover"program,displaytestcoverageresults.Thecovertoolispartofthego.toolssubrep

javascript - 如何使用 Angular-Translate 显示翻译?

Angular-translate与partial-loader结合只显示键而不是实际的翻译。我已经尝试了一切,但似乎无法找到错误。没有记录错误。这是我的代码:app.jsvarapp=angular.module('myapp',['ngRoute','appRoutes','pascalprecht.translate','angularTranslate','HomeCtrl']);angular.module('angularTranslate',['pascalprecht.translate']).config(function($translateProvider,$tr

javascript - 如何使用 Angular-Translate 显示翻译?

Angular-translate与partial-loader结合只显示键而不是实际的翻译。我已经尝试了一切,但似乎无法找到错误。没有记录错误。这是我的代码:app.jsvarapp=angular.module('myapp',['ngRoute','appRoutes','pascalprecht.translate','angularTranslate','HomeCtrl']);angular.module('angularTranslate',['pascalprecht.translate']).config(function($translateProvider,$tr

Python/Django : how to assert that unit test result contains a certain string?

在python单元测试(实际上是Django)中,正确的assert语句会告诉我我的测试结果是否包含我选择的字符串?self.assertContainsTheString(result,{"car":["toyota","honda"]})我想确保我的result至少包含我指定为上面第二个参数的json对象(或字符串){"car":["toyota","honda"]} 最佳答案 要断言一个字符串是否是另一个字符串的子字符串,你应该使用assertIn和assertNotIn:#Passesself.assertIn('bcd',