tdd

Cython & Python Project Test Driven Development and .pyx file structure advice

我的梦境 提交于 2019-12-10 02:57:55
问题 What is the best way to structure a python/cython project such that I can unit test code that resides in .pyx files? Is it possible to unit test this code in place or will refactoring allow me to achieve this in another way? I am new to cython but have experience with Python TDD, mocking etc. I am also aware that the decision to cythonise some of the python code base could have been a premature optimisation decision. I have just joined a new team and therefore I am working on an existing code

When is it preferable to store data members as references instead of pointers?

一世执手 提交于 2019-12-10 02:56:19
问题 Let's say I have an object Employee_Storage that contains a database connection data member. Should this data member be stored as a pointer or as a reference? If I store it as a reference, I don't have to do any NULL checking. (Just how important is NULL checking anyway?) If I store it as a pointer, it's easier to setup Employee_Storage (or MockEmployee_Storage ) for the purposes of testing. Generally, I've been in the habit of always storing my data members as references. However, this makes

DUnit: How to run tests?

核能气质少年 提交于 2019-12-10 02:56:13
问题 How do i run TestCase 's from the IDE? i created a new project, with a single, simple, form: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) private public end; var Form1: TForm1; implementation {$R *.DFM} end. Now i'll add a test case to check that pushing Button1 does what it should: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type

Mocking with Boost::Test

☆樱花仙子☆ 提交于 2019-12-10 01:47:44
问题 I'm using the Boost::Test library for unit testing, and I've in general been hacking up my own mocking solutions that look something like this: //In header for clients struct RealFindFirstFile { static HANDLE FindFirst(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData) { return FindFirstFile(lpFileName, lpFindFileData); }; }; template <typename FirstFile_T = RealFindFirstFile> class DirectoryIterator { //.. Implementation } //In unit tests (cpp) #define THE_ANSWER_TO_LIFE_THE_UNIVERSE_AND

How to unit test this line of LayoutInflater.from() in android

倖福魔咒の 提交于 2019-12-10 01:36:59
问题 Hi Am building a simple RecycleView Adapter and am trying to test all the methods of the adapter but the onCreateViewHolder is been dificult for me. @Override public NewsViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.fragment_news,parent,false); return new NewsViewHolder(v); } I Try using mockito to build a mock of the viewGroup class and return a spy of the MockContext when getContext() is call but it seems

Does YAGNI also apply when writing tests?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 01:08:44
问题 When I write code I only write the functions I need as I need them. Does this approach also apply to writing tests? Should I write a test in advance for every use-case I can think of just to play it safe or should I only write tests for a use-case as I come upon it? 回答1: I think that when you write a method you should test both expected and potential error paths. This doesn't mean that you should expand your design to encompass every potential use -- leave that for when it's needed, but you

How do you Unit Test an .EXE with 3rd party dll?

杀马特。学长 韩版系。学妹 提交于 2019-12-09 17:46:41
问题 I'm still learning the dark arts of TDD and recently I've been trying to learn how to do TDD in VB6 and what I basically narrow down the list to was the free simplyvbunit and the most costly vbunit3. My application is an richtext editor with plenty of 3rd party dll and I was scouring high and low in Google to find how to do unit test this exe file. So my question is how do you unit test an exe file? Especially in the context for VB6 and if you have any good example with vbunit3 or

How to run nosetests without showing of my matplotlib's graph?

假装没事ソ 提交于 2019-12-09 17:41:00
问题 I try to run my test without any messages displaying from my main program. I only want verbose messages from nosetests to display. For example: nosetests -v --nologcapture All of my printout messages from my main program will be gone. However, the graph that I call in my main program ( plt.show() from matplotlib) still shows up. How do I run the tests without matplotlib's graph showing up? 回答1: I assume that you're calling unittests on your code, so my recommendation would be for you to

Rhino Mocks Partial Mock

耗尽温柔 提交于 2019-12-09 16:43:12
问题 I am trying to test the logic from some existing classes. It is not possible to re-factor the classes at present as they are very complex and in production. What I want to do is create a mock object and test a method that internally calls another method that is very hard to mock. So I want to just set a behaviour for the secondary method call. But when I setup the behaviour for the method, the code of the method is invoked and fails. Am I missing something or is this just not possible to test

Evidence based studies on the topic of best programming practices? [closed]

蹲街弑〆低调 提交于 2019-12-09 12:22:43
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . When seeking advice on good programming practices the typical answers are a variation of agile software development, test driven development or design patterns. However, as far as I know, neither of these are proven using the scientific method (if I'm wrong on this then feel free to correct me). I wonder, are