Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.
0
votes
1answer
34 views
Should I make a seperate unit test for a method, if it only modifies the parent state?
Should classes, that modify the state of the parent class, but not itself, be unit tested separately? And by separately, I mean putting the test in the corresponding unit test class, that tests that ...
0
votes
2answers
109 views
How can a non-developer help promote/develop unit tests? [duplicate]
After some discussions with folks on the testing/QA side of our company, we're of the opinion that better unit-level testing by developers would greatly reduce bugs and issues and help development ...
0
votes
3answers
84 views
What concept am I missing with private methods and testing? [duplicate]
I've read a lot o blogs arguing about private methods and testing. Some people say you should not test private methods, they say you should make them public or put those methods in a new class.
But ...
20
votes
9answers
1k views
Is it a bad practice to modify code strictly for testing purposes
I have a debate with a programmer colleague about whether it is a good or bad practice to modify a working piece of code only to make it testable (via unit tests for example).
My opinion is that it ...
9
votes
3answers
405 views
Is this pattern bad?
I notice that when I code I often use a pattern that calls a class method and that method will call a number of private functions in the same class to do the work. The private functions do one thing ...
1
vote
1answer
61 views
Testcase runner for parametrized testcases
Let me explain my situation. I'm planning a kind of test case runner for doing testcases on external devices, which are microcontroller based. Lets consider the devices:
Device 1
Device 2
There ...
0
votes
1answer
56 views
Can automation QA/Tester work in SDET profile [closed]
Since two years I've been working in automation testing profile that involves developing test frameworks using selenium,watir,JUnit. I now want to enhance my profile technically. Over a period of time ...
3
votes
4answers
169 views
End-to-end tests versus unit tests, should tests be decoupled?
At our company we typically make sure that we write an end-to-end test for our websites/web apps. That means we access a URL, fill in a form, submit the form to another URL and check the results of ...
6
votes
3answers
285 views
Is there a point to unit tests that stub and mock everything public?
When doing unit tests the "proper" way, i.e. stubbing every public call and return preset values or mocks, I feel like I'm not actually testing anything. I'm literally looking at my code and creating ...
29
votes
8answers
9k views
Is static universally “evil” for unit testing and if so why does resharper recommend it?
I have found that there are only 3 ways to unit test (mock/stub) dependencies that are static in C#.NET:
Moles
TypeMock
JustMock
Given that two of these are not free and one has not hit release ...
2
votes
2answers
87 views
Should an integration test be used in place of a unit test involving personal data?
I am trying to develop a series of unit tests for a production system that are dependent on a person's social security number. While I am more than comfortable hard coding a clearly bad social ...
0
votes
2answers
80 views
when to mock in unit testing [duplicate]
I am trying to write unit tests in javascript for an application made in nodejs. What I want to know is -
Say there is a class Vehicles which is dependent on another class Roads.
Should I mock the ...
2
votes
4answers
126 views
Initializing derived classes in the same way
I have a class Base that has several children, say A, B, C. For testing purposes I'd like to mock those derived classes by deriving from them. So MockA derives from A, MockB derives from B and so on.
...
1
vote
3answers
112 views
How should test for a “for any different than x return false” requirement look like
I tried to find if there's a similar question but didn't even know what keywords should I use :)
I got a method in an interface accepting an other interface as a parameter:
bool CanDoIt(AnInterface ...
0
votes
0answers
60 views
Unit Tests for Database Abstraction Layer
I previously asked this question about creating an algorithm for joining records from multiple databases, and since then, I have built a rudimentary version of it (which doesn't allow for inter ...
0
votes
0answers
28 views
Unit Test the integration layer using CDI
JEE-CDI allows you to create applications integrating components with annotations and configuration files. What I call integration layer is the set of annotation and configuration file that enables ...
1
vote
2answers
269 views
Fundamental TDD: stuck with writing a test so I can write code that I want
I have a Season class. This Season has a few properties: among them, a list of Games. This should be populated from the same source that populated the rest of the Season properties.
I have a test ...
2
votes
1answer
88 views
Shared factories: good or bad?
RSpec allows users to share factories across tests / examples, which would reduce the number of code lines in my app by a significant amount.
On the other hand, one of the reasons why I'm using ...
5
votes
3answers
439 views
Unit Testing DatabaseOpenHelper class in Android
I've written several unit tests for an already existing DatabaseOpenHelper class. I covered the creation scenario and migration from old schema to new one. Unfortunately, I don't feel that my tests ...
3
votes
3answers
294 views
How to simplify my complex stateful classes and their testing?
I am in a distributed system project written in java where we have some classes which corresponds to very complex real-world-business objects. These objects have a lot of methods corresponding to ...
-2
votes
0answers
33 views
Telerik Silverlight Test automation vs MS Visual Studio 2010 Silverlight Unit Testing framework [closed]
We're currently evaluating the above mentioned tools for two things:
Unit testing Silverlight controls
Writing automated tests (black
box)
Has anyone done a comparison for the above scenarios ...
37
votes
8answers
13k views
How do you unit test private methods?
I am working on a java project. I am new to unit testing. What is the best way to unit test private methods in java classes?
5
votes
3answers
352 views
Time consuming Unit test for support for 100,000 records: Am I doing it right?
I am working on adding test coverage for an application that previously didn't have any. One additional requirement that emerged is that one of the background processes should be able to process ...
4
votes
6answers
251 views
Why don't I see many unit test projects that bring up and tear down a DB? (ASP.NET MVC)
I see all the examples that demonstrate unit testing code and mocking the calls to the DB since you are not suppose to touch the DB. But it seems to me having a set up tasks that uses the actually ...
8
votes
2answers
427 views
How to unit test method that returns a collection while avoiding logic in the test
I am test-driving a method that is to generate a collection of data objects. I want to verify that the properties of the objects are being set correctly. Some of the properties will be set to the same ...
62
votes
10answers
5k views
Is there a reason that tests aren't written inline with the code that they test?
I've been reading a bit about Literate Programming recently, and it got me thinking... Well-written tests, especially BDD-style specs can do a better job at explaining what code does than prose does, ...
4
votes
1answer
176 views
Unit testing in Django
I'm really struggling to write effective unit tests for a large Django project. I have reasonably good test coverage, but I've come to realize that the tests I've been writing are definitely ...
1
vote
2answers
126 views
How do you test database abstraction in PHP?
I apologise in advance if this question is too subjective but I'm struggling to find a good answer, probably as there is not really a correct answer to give.
I'm currently writing a database ...
1
vote
1answer
93 views
What is the most appropriate testing method in this scenario?
I'm writing some Objective-C apps (for OS X/iOS) and I'm currently implementing a service to be shared across them. The service is intended to be fairly self-contained.
For the current functionality ...
0
votes
0answers
143 views
Looking for a reference on tic tac toe moves
I want to wirte a testcase where each possible scenatio is played and the result is counted.
I am looking for a reference of tic tac toe moves to justify a test case. So far i tried counting in my ...
4
votes
5answers
266 views
How can I test parts of my application against the output of third party application?
I have a fairly new C# application, approximately 6 months old, that we are now trying to incorporate testing into. (Should have been done from the start but I can't change the past)
Parts of this ...
-2
votes
1answer
155 views
Do you unit-test your PODs? [closed]
do you create unit-tests for PODs (Plain Old Data Structure)? And why?
I'm interested in your opinions.
Regards
Tobias
20
votes
10answers
690 views
Automated Testing: Explaining its Business Value
To start I don't think this is a repeat of other questions on unit testing. What I'm looking for help with is articulating its value to a team of programmers, analysts, managers and testers. By ...
3
votes
1answer
161 views
How to keep unit tests independent?
I've read it at many places that unit tests should be independent. In my case I have a class that does data transformation. These steps must be done sequentially, otherwise they don't make sense. For ...
6
votes
4answers
357 views
What would help when refactoring a large method to ensure that I don't break anything?
I'm currently refactoring a part of a large codebase with no unit tests whatsoever. I tried to refactor code the brute way, i.e. by trying to guess what the code is doing and what changes wouldn't ...
26
votes
6answers
2k views
How should you TDD a Yahtzee game?
Let's say you're writing a Yahtzee game TDD style. You want to test the part of the code that determines whether or not a set of five die rolls is a full house. As far as I know, when doing TDD, you ...
1
vote
4answers
208 views
Unit Test code generation
We have a project that was written over a period of 2 years, but has a poorly designed architecture and not unit tests.
The software works well, but we're at the point where we want to refactor some ...
0
votes
1answer
97 views
Where to start with Unit Testing [closed]
I am currently working on some projects that are pretty large and intermingled. We have never done unit testing, and are beginning to realize that it would be a good thing to try to start but our ...
1
vote
1answer
126 views
Why do we write our specs in different files from our source?
The D Programming Language supports writing unit tests inline with source. There's a Ruby gem called test_inline that lets you write specs in the same file as your code.
Why is it generally ...
3
votes
4answers
304 views
How to determine most challenging test-cases to test any algorithm?
While solving any problem, we write algorithms. Some efficient, some not, some work, some fail. But sometimes we end up writing something which is mostly a success when we do a dry test run, perhaps, ...
0
votes
3answers
204 views
Is there an accepted name for a fake object injected via a preprocessor seam?
I am dealing with some old, sloppy C++ code in which there is a structure with a lot of data members and functions. I want to test a class that I have implemented which uses the struct, but this ...
3
votes
1answer
124 views
Unit Testing and “Fit”
I am reading Cristopher Alexander's "Notes on the Synthesis of Form", and he is describing a solution to a problem as having good fit, when there is an absence of bad fit; we can't describe all of the ...
8
votes
4answers
379 views
In Unit Testing, why would I create a Repository twice?
The other day I was reading a little about Unit Testing and I saw some examples where people create a repository interface (i.e. IExampleRepository) and then create the real repository (public class ...
2
votes
5answers
383 views
Unit test cases(JUnit), not by developer but other team members
I have a very interesting situation. Management has strictly asked to do unit testing for the code being developed and divided the task in such a way that few are developing the code and others are ...
0
votes
0answers
214 views
How to write unit tests without mocking data
My design doesn't allow me to mock the data so I am using sqlite as test database that has minimum data to run the unit tests. Below is the pseudo code
//Method to be tested
public IList<Funds> ...
12
votes
4answers
1k views
Resources for Test Driven Development in Web Applications? [closed]
I would like to try and implement some TDD in our web applications to reduce regressions and improve release quality, but I'm not convinced at how well automated testing can perform with something as ...
2
votes
2answers
181 views
How to unit test code which is intended to have different results on different platforms
I noticed some duplicate code in a codebase I am working on that appended a filename to a directory path, so I decided to refactor it into its own method. The application I am working on is not well ...
31
votes
10answers
4k views
How to write “good” unit tests?
Triggered by this thread, I (again) am thinking about finally using unit tests in my projects. A few posters there say something like "Tests are cool, if they are good tests". My question now: What ...
56
votes
8answers
6k views
Is it OK to have multiple asserts in a single unit test?
In the comment to this great post Roy Osherove pointed to the OAPT project that is designed to run each assert in a single test.
This is written on projects home page:
Proper unit tests should ...
9
votes
2answers
224 views
Orthogonality of unit tests vs. concision of unit tests
I'm writing unit tests for a steering system for a video game. The system has several behaviours (avoid this area because of reason A, avoid this area because of reason B, each adding a bit of context ...


