Tag: unit testing

在方法级别指定一个命令来联合4个testing(不是类级别)

我知道这是不好的做法,但需要做,否则我需要切换到testng 。 有没有类似于JUnit 3的testSuite的方法来指定要在类中运行的testing的顺序?

以某种顺序运行PHPUnittesting

有没有办法让TestCase的testing以一定的顺序运行? 例如,我想将一个对象的生命周期从创build到使用分解,但是在运行其他testing之前,我需要确保先设置对象。

运行OpenERP 7在PyCharm进行testing

我可以运行我的OpenERP v7加载项的unit testing,如下所述。 在PyCharm中,我通过在运行/debuggingconfiguration中添加了一个Pythonconfiguration,如下所示: 脚本: /home/juliocesar/work/projects/my_project/openerp-server 脚本参数: –addons-path=openerp/addons,openerp/addons/my_addons –log-level=test –database=my_project_db_test –db_host=localhost –db_user=test –db_password=123 –init=my_addon –test-enable –stop-after-init 它成功运行,但以文本日志格式显示标准输出,如下所示: 2015-04-24 13:47:55,101 12340 TEST my_project openerp.modules.module: module my_addon: executing 1 `fast_suite` and/or `checks` sub-modules 2015-04-24 13:47:55,101 12340 TEST my_project openerp.modules.module: test_change_old_received_to_contingency (openerp.addons.my_addon.tests.test_my_addon.TestMyItems) 2015-04-24 13:47:55,101 12340 TEST my_project openerp.modules.module: ` Test patch to change old received status to contingency. […]

我如何使用PHPUnit和Zend Framework?

我想知道如何用Zend_Test编写PHPUnittesting,一般用PHP编写。

我如何unit testing持久性?

作为一个实践testing驱动开发的新手,我经常会对如何将持久性unit testing到一个数据库感到尴尬。 我知道在技术上这将是一个集成testing(而不是unit testing),但我想找出以下的最佳策略: testing查询。 testing插入。 如何知道如果插入失败了? 我可以通过插入然后查询来testing它,但是怎样才能知道查询没有错? testing更新和删除 – 与testing插入相同 做这些的最佳做法是什么? 关于testingSQL:我知道这可以做到,但是如果我使用像NHibernate这样的O / R映射器,它会在用于输出查询的别名中附加一些命名瑕疵,因为这有点不可预知,我不确定我可以testing。 我应该放弃一切,只要相信NHibernate? 我不确定这是谨慎的。

Moq用对象参数validation

我正在尝试validation是一个类的参数。 正在testing的代码是好的。 错误在testing中。 我试了两种方法,都失败了。 这是我的尝试: 1: this.MockImageResizeFilter.Verify(m => m.Filter(this.UploadedFileData, new ImageFilterOptions() { Width = 256, Height = 256, })); 这总是失败,即使作为第二个parameter passing的对象具有相同的属性。 第一个参数validation正确。 2: this.MockImageResizeFilter.Setup(m => m.Filter(It.IsAny<byte[]>(), It.IsAny<ImageFilterOptions>())) .Callback<byte[], ImageFilterOptions>((data, options) => { Assert.AreEqual(this.UploadedFileData, data, "data"); Assert.AreEqual(filterOptions.Width, options.Width, "Width"); Assert.AreEqual(filterOptions.Height, options.Height, "Height"); } ); 这总是通过,即使它会失败。 callback中的断言确实失败,但是exception不会传递给外部上下文,因此testing总是通过。 你能帮我find我做错了什么吗?

用moq模拟静态属性

我很新使用MOQ 。 我正在创build一些unit testing用例到HttpModule ,一切正常,直到我按照如下命中一个static属性 this.applicationPath = (HttpRuntime.AppDomainAppVirtualPath.Length > 1) ? HttpRuntime.AppDomainAppVirtualPath : String.Empty; 我不知道如何创build像HttpRuntime.AppDomainAppVirtualPath static类和属性的HttpRuntime.AppDomainAppVirtualPath 。 context , request和response已经被我从moq获得的示例代码模拟得很好。 如果有人能帮助我,我将不胜感激。

如何在XCode中运行单个testing用例?

我知道最好的做法是在任何改变之后运行所有的unit testing用例,以确保不会破坏任何东西。 不过有时候,比如debugging,我真的只想运行一个testing用例。 看起来XCode并没有在UI中提供这样的function,而其他的testing框架如JUnit也有这样的function。 是否有任何解决方法只有一个testing用例在XCode中运行? PS大部分testing用例都是逻辑testing。 所以,他们不在iPhone设备上运行。

angularjs路由unit testing

正如我们在http://docs.angularjs.org/tutorial/step_07中看到的, angular.module('phonecat', []). config(['$routeProvider', function($routeProvider) { $routeProvider. when('/phones', {templateUrl: 'partials/phone-list.html', controller: PhoneListCtrl}). when('/phones/:phoneId', {templateUrl: 'partials/phone-detail.html', controller: PhoneDetailCtrl}). otherwise({redirectTo: '/phones'}); }]); build议使用e2etesting进行路由testing, it('should redirect index.html to index.html#/phones', function() { browser().navigateTo('../../app/index.html'); expect(browser().location().url()).toBe('/phones'); }); 不过,我认为'$ routeProvider'configuration是使用单个函数($ routeProvider)完成的,我们应该能够在不涉及浏览器的情况下进行unit testing,因为我认为路由function不需要浏览器DOM。 例如, 当url是/ foo时,templateUrl必须是/partials/foo.html而控制器是FooCtrl 当url是/ bar时,templateUrl必须是/partials/bar.html,而控制器是BarCtrl 这是一个简单的IMO函数,它也应该在一个简单的testing中进行testing,一个unit testing。 我googlesearch这个$ routeProviderunit testing,但没有运气。 我想我可以从这里借用一些代码,但不能做到这一点, https://github.com/angular/angular.js/blob/master/test/ng/routeSpec.js 。

命名约定JUnit后缀或前缀Test

testing下的类MyClass.java JUnittesting用例名称的替代方法: TestMyClass.java MyClassTest.java http://moreunit.sourceforge.net似乎使用“testing”作为前缀默认,但我已经看到了这两个用途。 在eclipse中运行整个项目作为unit testing时,它们似乎都被认可,因为它是@Test分析的类中的注释。 我猜maven做同样的事情。 哪个是首选?