tdd

Functional Test for QMessageBox… why does not work?

左心房为你撑大大i 提交于 2020-06-28 08:41:10
问题 I would develop some functional tests for a pyqt application that uses PyQt (or PySide) as GUI library. The tests use Unittest and Qttest library, as reported in many resources, for example this stackoverflow question: Unit and functional testing a PySide-based application? For the main window all works fine, and the code simulate perfectly Keyboard Types and Mouse Clicks and Movements, but the " devil is in the details "... and this method does not work for a QMessageBox. In the class of the

Functional Test for QMessageBox… why does not work?

天大地大妈咪最大 提交于 2020-06-28 08:41:08
问题 I would develop some functional tests for a pyqt application that uses PyQt (or PySide) as GUI library. The tests use Unittest and Qttest library, as reported in many resources, for example this stackoverflow question: Unit and functional testing a PySide-based application? For the main window all works fine, and the code simulate perfectly Keyboard Types and Mouse Clicks and Movements, but the " devil is in the details "... and this method does not work for a QMessageBox. In the class of the

TDD: best practices mocking stacks of objects

自作多情 提交于 2020-05-16 19:09:51
问题 I'm trying to get familiar with unit testing in PHP with a small API in Lumen. Writing the first few tests was pretty nice with the help of some tutorials but now I encountered a point where I have to mock/ stub a dependency. My controller depends on a specific custom interface type hinted in the constructor. Of course, I defined this interface/implementation-binding within a ServiceProvider. public function __construct(CustomValidatorContract $validator) { // App\Contracts

How to use gmock to mock up a std::function?

北慕城南 提交于 2020-05-16 03:25:07
问题 The constructor of my class is A( ... std::function<bool(const std::string&, const std::string&)> aCallBack, ... ); I want to use EXPECT_CALL to test it. This callback is from another class B. I created a Mock like class BMock : public B { MOCK_METHOD2( aCallBack, bool(const std::string&, const std::string&) ); } Then I tried B *b = new B(); std::function<bool(const std::string&, const std::string&)> func = std::bind(&B::aCallBack, b, std::PlaceHolders::_1, std::PlaceHolders::_2); It still

Test(TDD)

我们两清 提交于 2020-03-24 01:08:34
3 月,跳不动了?>>> 测试分类 单元测试:白盒测试|开发人员测试|方法测试|单类测试 集成测试:灰盒测试|开发人员测试|类关联测试|模块测试 系统测试:黑盒测试|开发人员测试|模块集成测试|功能测试|端到端测试| 验收测试:黑盒测试|客户测试|功能测试|端到端测试|交互测试|可用性测试|性能测试|压力测试 测试环境 Dev环境测试: 单元测试|集成测试 Intg环境测试:单元测试|集成测试|系统测试|验收测试 Test环境测试:系统测试|验收测试 Prod环境测试:验收测试 测试过程 1) 明确当前要完成的功能。可以记录成一个 TODO 列表。 2) 快速完成针对此功能的测试用例编写。 3) 测试代码编译不通过。 4) 编写对应的功能代码。 5) 测试通过。 6) 对代码进行重构,并保证测试通过。 7) 循环完成所有功能的开发。 测试原则 测试隔离 。不同代码的测试应该相互隔离。对一块代码的测试只考虑此代码的测试,不要考虑其实现细节(比如它使用了其他类的边界条件)。 一顶帽子 。开发人员开发过程中要做不同的工作,比如:编写测试代码、开发功能代码、对代码重构等。做不同的事,承担不同的角色。开发人员完成对应的工作时应该保持注意力集中在当前工作上,而不要过多的考虑其他方面的细节,保证头上只有一顶帽子。避免考虑无关细节过多,无谓地增加复杂度。 测试列表 。需要测试的功能点很多

Get name of running test in Xunit

回眸只為那壹抹淺笑 提交于 2020-03-18 03:26:26
问题 Using Xunit, how can I get the name of the currently running test? public class TestWithCommonSetupAndTearDown : IDisposable { public TestWithCommonSetupAndTearDown () { var nameOfRunningTest = "TODO"; Console.WriteLine ("Setup for test '{0}.'", nameOfRunningTest); } [Fact] public void Blub () { } public void Dispose () { var nameOfRunningTest = "TODO"; Console.WriteLine ("TearDown for test '{0}.'", nameOfRunningTest); } } Edit: In particular, I am looking for a replacement for NUnits

How do I recover when tSQLt faketable does not reset table mapping?

瘦欲@ 提交于 2020-03-17 05:55:08
问题 faketable function did not reassign to normal. All my tables I used faketable on now contain the content of the values I used in the insert of the unit test. It was many tables and it has left my database useless. Please help address this problem or at least its cause. This makes me very nervous about using this in our CI deployment process and maybe more importantly in our local development efforts. 回答1: It is possible one of your tests or your code, left the transaction in a state where it

【卡片记忆】iOS 单元测试查看覆盖率

主宰稳场 提交于 2020-03-03 21:29:39
###iOS 覆盖率 https://github.com/knight2010/XcodeCoverage ###定义API的需求 为添加到项目中的每个方法或者函数定义需求和结果非常重要。对于需求,包括输入和输出范 围,exceptions 抛出异常,条件限制,以及返回值的类型(尤其如果值是类的实例时)。定义 要求并确保满足代码中的需求可以帮助你编写出健壮的安全的代码。 ###边写边测 每当你设计和编写一个方法或函数时,就应该编写一个或多个测试用例来确保API的需求得到满 足。记住,为现有代码编写测试要比为你正在编写的代码难得多。 ###检查边界条件 如果对一个方法的参数值必须在特定范围内,你的测试应包括该范围的最低值和最高值。例 如,如果一个程序有一个整数参数,那么该参数值的范围要在 0 和 100 之间(包括首尾值), 该方法的测试代码应该为参数传递0,50和100这些值。 ###使用negative测试 negative 测试可以确保您的代码能适当地响应出错的条件。当收到无效的或意外的输入值时, 它可以验证代码的行为。同样的,还可以验证它返回错误代码或引发异常时的行为。例如,如 果一个整数参数范围必须为 0到100(包含首尾值),创建测试用例并传值 -1 和 101,以确保 该程序能引发一个异常或返回一个错误代码。 ###编写全面的测试用例

Testing a method called many times in moq

我只是一个虾纸丫 提交于 2020-03-01 04:53:05
问题 I have an interface like so: Interface IWriteFile { string FileName {get;set;} void Open(); void WriteData(string dataToWrite); void Close(); } I want to test a class that will use this interface to populate a file. It will be calling WriteData a bunch of times and I just want to test the final output. Is there a way to introduce a new private field to the Mock object that will get appended to each time WriteData(Data) is called? I really just want to see what the file will look like at the

How to Test façade classes with no args constructors and no setters with TDD?

 ̄綄美尐妖づ 提交于 2020-02-29 07:46:35
问题 This question comes a bit as continuation of the following topic (you don't need to read it, though). It's just a game of Tetris I'm implementing with TDD. So here is the problem: I have a set of Acceptance tests. I have defined the following test in one of them: [TestMethod] public void I_Can_Query_Any_Piece_Of_The_Board_For_A_Color() { StandardTetris tetris = new StandardTetris(); for (int y = 0; y < tetris.BoardSize.Height; ++y) { for (int x = 0; x < tetris.BoardSize.Width; ++x) { Color