A unit is the smallest testable part of an application. In procedural programming, a unit may be an individual function or procedure. Unit tests are created by programmers or occasionally by white box testers.
1
vote
1answer
82 views
Testing thread safety
Say you have a function f that is or contains a critical section. How would you unit test that only one thread can run it at once, that it doesn't have race conditions, and that it doesn't cause a ...
7
votes
5answers
137 views
How to use unit tests as a source of information?
A colleague of mine was one a seminar about agile development, where he heard it is possible to use unit tests as a technical documentation. Something like using unit tests as example how to use the ...
1
vote
2answers
24 views
Should Multiple Data Items be in Multi Unit Test Methods?
I often want to have the same unit test applied to data multiple items that are roughly equivalent (two non-empty strings). Currently I implement these in multiple unit test methods, with names like ...
3
votes
4answers
162 views
Testing a file that relies heavily on a static array
I have a .c file that basically manages its own little database of people. There are add, remove, edit and search functions among some others. It has a static array which it uses to store the data.
...
13
votes
10answers
790 views
Has test driven development (TDD) actually benefited a real world project?
I am not new to coding. I have been coding (seriously) for over 15 years now. I have always had some testing for my code. However, over the last few months I have been learning test driven ...
3
votes
1answer
80 views
What open source POSIX compliance test suites are available?
I'm working on a small open source project, ELLCC, that uses clang/LLVM as a cross compiler for various target processors. For the runtime environment, I'm using the NetBSD libraries and porting them ...
2
votes
2answers
105 views
Looking for good testing in multithreaded C or C++ open source projects
I have read a lot about the importance of unit testing, and testing in general. In particular I have read about TDD which, in theory, seems like a good way to ensure effective test coverage for a ...
35
votes
10answers
1k views
How should I test randomness?
Consider a method to randomly shuffle elements in an array. How would you write a simple yet robust unit test to make sure that this is working?
I've come up with two ideas, both of which have ...
8
votes
5answers
251 views
switch statement - handling default case when it can't be reached
If I'm using a switch statement to handle values from an enum (which is owned by my class) and I have a case for each possible value - is it worth adding code to handle the "default" case?
enum ...
4
votes
4answers
205 views
Unit testing: about easy- and hard-first strategies
I've never written a unit test.
I'm reading The art of Unit Testing by Osherove, and he explains a way to choose where to start when you're writing tests for legacy code. Basically you end up with ...
49
votes
16answers
2k views
When is unit testing inappropriate or unnecessary?
It seems to be generally assumed (on Stack Overflow at least) that there should always be unit tests, and they should be kept up to date. But I suspect the programmers making these assertions ...
-3
votes
2answers
83 views
Systematic Testing
Can anyone please explain to me what is systematic testing? If say I'm developing a mobile application and need to do systematic testing; what would that be involved?
4
votes
6answers
290 views
Can the Strategy pattern be implemented without significant branching?
The Strategy pattern works well to avoid huge if...else constructs and make it easier to add or replace functionality. However, it still leaves one flaw in my opinion. It seems like in every ...
4
votes
1answer
105 views
What and how to unit test a django web application?
I am writing unit tests for a web frontend implemented in Django.
I have written unit tests that check that all views return the correct status code (200, 302 etc) so that template errors (which give ...
16
votes
4answers
387 views
How do I write unit tests for robots (and other mechanical devices)?
I'm a member of my high school's robotics club, and am responsible for programming the robot. One suggestion I keep hearing from various adults is that I should be writing unit tests to help validate ...
2
votes
1answer
100 views
Virtual Machines And Unit/Integration Testing Web Application
I am in the process of adding unit testing to a project I am working on at work and a suggestion came up that I should use VMs to populate the database with good data. This was suggested as an ...
9
votes
3answers
271 views
Real-world examples of apps written with TDD and good test coverage?
Are there any open source applications that are developed using test driven development that serve as models of how good unit testing should work?
I'd prefer to see examples in C# and .NET. (Note ...
0
votes
3answers
135 views
Is Debug.Assert obsolete if you write unit tests?
Just like the question asks, is there a need to add Debug.Assert into your code if you are writing unit tests (which has its own assertions)? I could see that this might make the code more obvious ...
-1
votes
2answers
126 views
any good short papers about TDD [closed]
I have so many years without coding with unit testing and I need a refresh to my acknowledgement about it so, If anybody could recommend me a couple of tutorials and papers about it, will be ...
4
votes
8answers
431 views
Testing loses its effectiveness if all programmers don't use them
Let's assume you are convinced that the extra time spent unit testing has merit and improves production. Does that still hold up when everyone working on the same code doesn't use them? This question ...
0
votes
1answer
47 views
Compatibility Test and other testing method to use while building software
I will be adding a feature to the software and have to update or modify some of public API of the present open source software.
What are steps which could be taken to ensure the compatibility of the ...
2
votes
3answers
187 views
Development processes, the use of version control, and unit-testing [closed]
Preface
I've worked at quite a few "flat" organizations in my time. Most of the version control policy/process has been "only commit after it's been tested". We were constantly committing at each ...
5
votes
2answers
81 views
CI tests to enforce specific development rules - good practice?
The following is all purely hypothetical and any particular portion of it may or may not accurately describe real persons or situations, whether living, dead or just pretending.
Let's say I'm a ...
0
votes
2answers
142 views
Should I use a seperate class per test?
Taking the following simple method, how would you suggest I write a unit test for it (I am using MSTest however concepts are similar in other tools).
public void MyMethod(MyObject myObj, bool ...
43
votes
17answers
2k views
Why not write all tests at once when doing TDD?
The Red - Green - Refactor cycle for TDD is well established and accepted. We write one failing unit test and make it pass as simply as possible. What are the benefits to this approach over writing ...
3
votes
2answers
146 views
How and what should I be (unit) testing for in this method?
I am relatively new to unit testing and have a query about what/how I should be testing a certain method. For the following (psudo-c#) method I have created (not a real-life example) what would you ...
0
votes
1answer
101 views
Differences between software testing processes and techniques?
I get confused between these terms. For example, should unit testing be listed as a software testing process or technique? I think unit testing is a software testing technique. And how about Test ...
1
vote
4answers
79 views
Is application-specific data required for good unit testing?
I am writing unit tests for a fairly simple function that depends on a fairly complicated set of data. Essentially, the object I am manipulating represents a graph and this function determines whether ...
0
votes
1answer
67 views
Are there any open source libraries that have file integration tests
I am writing integration tests to ensure files are getting created and written to etc but this seems like something lots of people must have done previously.
Are there any libraries that have a bunch ...
8
votes
3answers
481 views
What arguments can I use to “sell” the BDD concept to a team reluctant to adopt it?
I am a bit of a vocal proponent of the Behaviour Driven Development methodology (aka BDD). I've been applying BDD for a couple of years now, and have adopted StoryQ as my framework of choice when ...
18
votes
6answers
615 views
Is dependency injection essential for unit testing?
Is using dependency injection (DI) essential for unit testing?
I can't think of another alternative for isolating code so it can be tested. Also, all the examples I have ever seen use this pattern. ...
0
votes
1answer
189 views
Implementing a ILogger interface to log data
I have a need to write data to file in one of my classes.
Obviously I will pass an interface into my class to decouple it.
I was thinking this interface will be used for testing and also in other ...
1
vote
5answers
144 views
Should I use a unit testing framework to validate XML documents?
From http://www.w3.org/XML/Schema:
[XML Schemas] provide a means for defining the structure, content and semantics of XML documents.
I'm using an XML Schema (XSD) to validate several large XML ...
8
votes
5answers
435 views
Is it OK to repeat code for unit tests?
I wrote some sorting algorithms for a class assignment and I also wrote a few tests to make sure the algorithms were implemented correctly. My tests are only like 10 lines long and there are 3 of ...
1
vote
2answers
176 views
How much extra time is needed to add unit test in a development task?
My team is considering moving to test-driven development. Currently we have almost no unit testing, we have been only relying on the user acceptance test, and developer's own manual test. Not everyone ...
29
votes
9answers
1k views
Is unit testing or test-driven development worthwhile?
My team at work is moving to Scrum and other teams are starting to do test-driven development using unit tests and user acceptance tests. I like the UATs, but I'm not sold on unit testing for ...
1
vote
1answer
118 views
Is there a good example of Python code for unit testing an api?
Do you know any good example of Python unit testing code for testing an API?
Thanks!
Update:
Found this very interesting question: ...
1
vote
3answers
190 views
How to Console.WriteLine from [TestMethod]?
I am trying to show some information from a [TestMethod] method.
Usually we use NUnit and a line with Console.WriteLine runs fine and we can see it in 'output' window, but on this project we must to ...
3
votes
1answer
107 views
How can I test a parser for a bespoke XML schema?
I'm parsing a bespoke XML format into an object graph using .NET 4.0. My parser is using the System.XML namespace internally, I'm then interrogating the relevant properties of XmlNodes to create my ...
10
votes
7answers
320 views
Unit testing - Database coupled app
What would be the best approach at unit testing a model that integrates into an application that is tightly coupled to database?
The specific scenario here is a shopping cart - I'd like to be able to ...
3
votes
2answers
75 views
Learning system instead of using sed/replace for reviewing test results
For every build of my software I run it through a series of tests that execute a number of commands on a command line and captures the results.
Most of the time the output is a combination of:
- ...
2
votes
1answer
63 views
Testing chainable method calls return type and value
Is it worth testing the return type and value of a method call that is designed for chaining? It is conceivable that a fellow programmer could accidentally change the return type to void and remove ...
15
votes
3answers
416 views
Add a unit test for each new bug
In my job all developers that resolve a bug have to add a new unit test that warns about this type of bugs (in the case it occours again). If a unit test is not possible (for example, a webpage design ...
5
votes
4answers
142 views
Type mocking frameworks does not change coding practices from testability point?
Many people recommend that we should code against interfaces and avoid statics for testability.
Interfaces are not just for testability, they are sometimes a requirement. But sometimes we introduce ...
14
votes
6answers
695 views
Do I really need a unit test framework?
Currently at my job, we have a large suite of unit tests for our C++ application. However we don't use a unit test framework. They simply utilize a C macro that basically wraps an assert and a cout. ...
3
votes
2answers
120 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 ...
3
votes
1answer
147 views
Unit testing invalid inputs; ArgumentException vs. Custom Exception
In unit tested code I often have multiple checks on the arguments on any method before the actual "work" of the method is begun:
public void DoSomething(string test)
{
if ...
6
votes
7answers
170 views
Creating Unit Tests on a CRUD layer of an Application, how can I make the tests independent?
So I'm trying to make my Unit Tests as by-the-book as possible, but it becomes troublesome when I'm testing some simple Add/Delete methods.
For the add method, I basically have to create a dummy ...
2
votes
1answer
90 views
In javascript and other languages which lack a compiler, is unit testing a good method to ensure correct syntax and variable naming?
I've been working on a medium sized web application that makes very heavy use of javascript. I tend to introduce common errors per 10 lines of code with either an unknown variable name or function ...
0
votes
1answer
465 views
How do I use PowerMock / Mockito / EasyMock to use a mocked object for dependency injection?
I have an AuthenticationManager.authenticate(username,password) method that gets called in someMethod of a SomeService under test. The AuthenticationManager is injected into SomeService:
@Component
...