Questions tagged [unit-testing]
Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.
1,733
questions
5
votes
5
answers
460
views
Unit testing coverage
How much of your code do you unit test? Do you try to get 100% coverage of everything or do you skip some classes?
Background
We've made a lightweight ORM layer which we have written plenty of tests ...
16
votes
6
answers
12k
views
Parameterized tests - When and why do you use them?
Recently at work we've been having some differences of opinion with regard to Parameterized testing. Normally we use a TDD-style (or at least try to) so I understand the benefits of that approac. ...
5
votes
6
answers
8k
views
C# Unit Testing In A Single Project
Alright, so I'm doing my first "real" C# project. I'm chugging along, enjoying myself, nice little language I've got here, fairly easy to use, la ti da. Then I get to the point that I realize there'...
11
votes
5
answers
5k
views
Why do we write mock objects when writing unit test cases?
We are currently writing unit test cases in our project . The implementations for database methods exist and is working fine . In this case why do we need to write mock objects ? Is there any specific ...
16
votes
4
answers
5k
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 ...
24
votes
1
answer
2k
views
What is the effect of creating unit tests during development on time to develop as well as time spent in maintenance activities?
I'm a consultant and I am going to introduce unit tests to all developers at my client site. My goal is to ensure that all new applications should have unit tests for all classes created.
The client ...
2
votes
1
answer
423
views
Unit test storage on Android apps
I've been experimenting recently with Android applications.
I've developed the convention (which I've seen used elsewhere) of placing my unit tests in a parallel source folder within an Eclipse ...
73
votes
7
answers
64k
views
Difference Between Unit Testing and Test Driven Development
From reading the descriptions, I understand that in TDD tests are done prior to writing the function and in Unit Testing, its done afterwards.
Is this the main difference, or the two terms can't even ...
13
votes
8
answers
7k
views
What is the value of checking in failing unit tests?
While there are ways of keeping unit tests from being executed, what is the value of checking in failing unit tests?
I will use a simple example: Case Sensitivity. The current code is case sensitive....
6
votes
3
answers
2k
views
How can I reduce the amount of time it takes to fully regression test an application ready for release?
An app I work on is being developed with a modified version of scrum. If you are not familiar with scrum, it's just an alternative approach to a more traditional watefall model, where a series of ...
6
votes
2
answers
2k
views
OOP for unit testing : The good, the bad and the ugly
I have recently read Miško Hevery's pdf guide to writing testable code in which its stated that you should limit your classes instanciations in your constructors. I understand that its what you should ...
3
votes
2
answers
308
views
How can Agile methodologies be adapted to High Volume processing system development?
I am developing high volume processing systems. Like mathematical models that calculate various parameters based on millions of records, calculated derived fields over milions of records, process huge ...
4
votes
2
answers
973
views
Unit Tests as a learning tool - a good idea? [closed]
I'm interested in ways and means for learning (a) programming language(s) efficiently. I believe that using Unit Test concepts and infrastructure early in that process is a good thing, even better ...
3
votes
4
answers
2k
views
Do you write common pre-conditions for a large number of unit test cases?
I have heard/read writing common pre-conditions for a large number of test cases is a bad thing, since this dependency may cause large number of test cases to fail if something changes . What are your ...
10
votes
2
answers
581
views
How do you unit test your javascript
I spend a lot of time working in javascript of late. I have not found a way that seems to work well for testing javascript. This in the past hasn't been a problem for me since most of the websites I ...
14
votes
6
answers
37k
views
How do you write unit test cases?
Sometimes I end up writing unit test cases for code that other developers have written. There are occasions when I really don't know what the developer is trying to do (the business part) and I just ...
0
votes
3
answers
426
views
How to verify the code that could take a substantial time to compile? [closed]
As a follow up to my prev question:
What is the best aproach for coding in a slow compilation environment
To recap: I am stuck with a large software system with which a TDD ideology of "test often" ...
16
votes
6
answers
6k
views
Convert from Procedural to Object Oriented Code
I have been reading Working Effectively with Legacy Code and Clean Code with the goal of learning strategies on how to begin cleaning up the existing code-base of a large ASP.NET webforms application.
...
19
votes
9
answers
2k
views
What to do as a new team lead on a project with maintainability problems?
I have just been put in charge of a code project with maintainability problems. What things can I do to get the project on a stable footing?
I find myself in a place where we are working with a very ...
26
votes
4
answers
23k
views
What is the best unit test framework for .NET and why? [closed]
It seems to me that everyone uses NUnit without even considering the other options. I think this is because:
Everyone is familiar with it already so they won't have to learn a new API.
It is already ...
6
votes
4
answers
2k
views
Unit testing data access objects
I have recently started using test-driven development and unit testing, and it has paid off immensely in the areas where I have aplied it. One area that it has been helpful in is database access. When ...
7
votes
2
answers
2k
views
Looking for statistics on automated testing, continuous integration and refactoring usage
Are there any credible sources of information on the adoption of agile techniques like automated testing, continuous integration and refactoring?
Of those that are using unit testing, how many ...
3
votes
3
answers
261
views
When creating an library published on CodePlex, how "bad" would it be for the unit-test projects to rely on commercial products?
I have started a project on CodePlex for a WebDAV server implementation for .NET, so that I can host a WebDAV server in my own programs. This is both a learning/research project (WebDAV + server ...
15
votes
4
answers
1k
views
Advancing code review and unit testing practice
As a team lead managing a group of developers with no experience ( and see no need) in code review and unit testing, how can you advance code review and unit testing practice?
How are you going to ...
1
vote
5
answers
5k
views
Onsite Interview : QA Engineer with more Emphasis on Java Skills [closed]
I'm having a onsite interview for QA engineer with Startup. While phone interview the person said he would want to test my JAVA, JUnit and SQL skills on white board with more importance on Object-...
6
votes
2
answers
3k
views
How would you TDD the functionality of getting the corresponding process of a running windows service?
Purpose
Over the last year or more I've been learning unit testing via books I've read recently like The Art of Unit Testing, Working Effectively with Legacy Code, and others. I've also been using ...
5
votes
2
answers
608
views
how to fully unit test functions and their internal validation
I am just now getting into formal unit testing and have come across an issue in testing separate internal parts of functions.
I have created a base class of data manipulation (i.e.- moving files, ...
15
votes
10
answers
1k
views
At what point would you drop some of your principles of software development for the sake of more money?
I'd like to throw this question out there to interestingly see where the medium is.
I'm going to admit that in my last 12 months, I picked up TDD and a lot of the Agile values in software development....
8
votes
5
answers
392
views
How do I check that my tests were not removed by other developers?
I've just came across an interesting collaborative coding issue at work.
I've written some unit/functional/integration tests and implemented new functionality into application that's got ~20 ...
2
votes
2
answers
2k
views
Unit testing code paths
When unit testing using expectations, you define a set of method calls and corresponding results for those calls. These define the path through the method that you want to test.
I have read that unit ...
2
votes
2
answers
1k
views
Using JSTestdriver to test UI/DOM?
Can JSTestDriver be used to test DOM behaviors and interactions?
I see I can write tests to exercise pure JS but how do I go about testing against HTML or DOM?
Can I deliver with each test HTML for ...
24
votes
12
answers
2k
views
Colleague unwilling to use unit tests "as it's more to code"
A colleague is unwilling to use unit tests and instead opting for a quick test, pass it to the users, and if all is well it is published live. Needless to say some bugs do get through.
I mentioned ...
18
votes
4
answers
2k
views
Staying OO and Testable while working with a database
What are some OOP strategies for working with a database but keeping things unit testable? Say I have a User class and my production environment works against MySQL. I see a couple possible approaches,...
7
votes
2
answers
2k
views
How do I inject test objects when the real objects are created dynamically?
I want to make a class testable using dependency injection. But the class creates multiple objects at runtime, and passes different values to their constructor. Here's a simplified example:
public ...
12
votes
4
answers
1k
views
Gradual approaches to dependency injection
I'm working on making my classes unit-testable, using dependency injection. But some of these classes have a lot of clients, and I'm not ready to refactor all of them to start passing in the ...
8
votes
1
answer
247
views
Learning a new language using broken unit tests [closed]
I was listening to a dot net rocks the other day where they mentioned, almost in passing, a really intriguing tool for learning new languages -- I think they were specifically talking about F#.
It's ...
14
votes
4
answers
2k
views
When should I use mock objects?
I've read a lot of things about TDD but I still have doubts. For example, I have these class diagrams:
It's a simple example, just to learn about TDD and mock objects.
Which test should I write ...
31
votes
7
answers
13k
views
Automated unit testing, integration testing or acceptance testing [closed]
TDD and unit testing seems to be the big rave at the moment. But it is really that useful compared to other forms of automated testing?
Intuitively I would guess that automated integration testing is ...
17
votes
2
answers
3k
views
What practices exist for locale-specific unit testing?
We recently discovered a locale specific issue in our application and while it was easy to fix (once we figured out what was going on), it got the team I'm on thinking about unit testing practices in ...
2
votes
1
answer
438
views
Should I use native android junit framework?
Can anybody share a reason (or list of reasons) of not using the native android junit framework but a standalone one like robolectric or something like that?
I'm just trying to understand what ...
34
votes
9
answers
6k
views
What are the disadvantages of writing code before writing unit tests?
I have always seen the recommendation that we should first write unit tests and then start writing code. But I feel that going the other way is much more comfortable (for me) - write code and then the ...
3
votes
2
answers
718
views
Term for unit testing that separates test logic from test result data [closed]
So I'm not doing any unit testing. But I've had an idea to make it more appropriate for my field of use. Yet it's not clear if something like this exists, and if, how it would possibly be called.
...
24
votes
5
answers
11k
views
Why is testing MVC Views frowned upon?
I'm currently setting the groundwork for an ASP.Net MVC application and I'm looking into what sort of unit-tests I should be prepared to write. I've seen in multiple places people essentially saying '...
10
votes
1
answer
1k
views
Have unit test generators helped you when working with legacy code?
I am looking at a small (~70kLOC including generated) C# (.NET 4.0, some Silverlight) code-base that has very low test coverage. The code itself works in that it has passed user acceptance testing, ...
9
votes
4
answers
1k
views
A new name for unit tests [closed]
I never used to like unit testing. I always thought it increased the amount of work I had to do.
Turns out, that's only true in terms of the actual number of lines of code you write and furthermore, ...
12
votes
3
answers
3k
views
How does NUnit for C# compare with Unit Test facility integrated with Visual Studio
I need to work in a team to develop a mid scale Desktop application developed using C# .NET. Prior to this, I have not applied Unit Testing and Test Driven Development. I am aware that there exists ...
3
votes
5
answers
3k
views
Do you test your SQL/HQL/Criteria?
Do you test your SQL or SQL generated by your database framework?
There are frameworks like DbUnit that allow you to create real in-memory database and execute real SQL. But its very hard to use(not ...
6
votes
1
answer
594
views
Dependency injection: what belongs in the constructor?
I'm evaluating my current PHP practices in an effort to write more testable code. Generally speaking, I'm fishing for opinions on what types of actions belong in the constructor. Should I limit things ...
10
votes
2
answers
3k
views
design pattern for unit testing? [duplicate]
I am beginner in developing test cases, and want to follow good patterns for developing test cases rather than following some person or company's specific ideas. Some people don't make test cases and ...
11
votes
2
answers
3k
views
What is an "assertion framework"?
I was reading about the js-test-driver unit-testing framework, when I found out that the guys behind the framework intend it to be integrated with an assertion framework. What is an assertion ...