Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.

learn more… | top users | synonyms (1)

0
votes
1answer
18 views

Unit testing the variables passed to the view from the controller

Let's say I want to test a controller that gets some value from a service and then pass some of all of those values to the view. Do you test that the view gets the result that the controller took ...
7
votes
5answers
981 views

Sharing development test cases (unit and development integration) with the QA (test) team?

The testing team (the so-called QA team in some organizations) insists that the development team should share their (the development team's) test cases with them. Their arguments are that the ...
6
votes
5answers
506 views

How to do Test Driven Development

I have just 2+ years of experience in application development. In those two years my approach towards development was as following Analyze requirements Identity Core component/Objects, Required ...
0
votes
3answers
116 views

What's the idea behind mocking data access in unit tests [duplicate]

I understand that you're not actually supposed to hit the database or disk when doing unit tests... Why is that? Also, taking something like Moq, what is it actually supposed to mock and where? For ...
2
votes
1answer
265 views

2 questions about TDD

I'm just starting to get to grips with TDD, and I have 2 quick questions; I'm assuming that if I were writing software for a software company, that TDD would work alongside the software design? i.e ...
0
votes
2answers
91 views

Mocking the context of application

We have a context of the application which is a static class named Holder containing several static properties initialized by objects that are used throughout the application. All over the unit tests ...
5
votes
6answers
442 views

When should you start unit testing? (during which development stage?)

I'm currently learning about unit testing, specifically JUnit (with Java). Searching the web I see many threads talking about why you should use it, what type of methods you should use it with but I ...
-3
votes
0answers
25 views

Visual Studio Team Test: How to unit test “?” operator with only Asserts() and not using any tool [migrated]

I need to write some unit test cases to test my code in C# Visual Studio Team Test framework. Below is the method I want to test: public static Association CreateAssociationFromXrm(Xrm.pv_association ...
2
votes
2answers
120 views

How much should I break up my unit tests?

I recently learned about unit tests and TDD and have started going back to add unit tests to my code (and thank god, it's proven that some things I've written are much more broken than I thought). ...
5
votes
4answers
205 views

Unit testing when it's harder to come up with concrete cases than write the logic

I have little experience with unit testing, but at the project we're working on right now we decided to do unit testing. The project is a WPF/Entity Framework application, and the part I'm being ...
0
votes
3answers
74 views

Unit testing method that calls multiple private methods

I've been reading a lot about unit testing recently and there seems to be a debate online about whether private methods should be tested or not. If I have an interface that exposes one method, but ...
0
votes
2answers
74 views

Should I put the name of the method I'm testing in the Unit Test method's name/assert message?

Given that a method's name might change in time, is it a good idea to specify the name of the method whose return value I am asserting as a part of the Unit Test method's name? What about the message ...
9
votes
3answers
700 views

In TDD should I have to write Test first or Interface first?

I am learning TDD using c#, as far as I know test should drive the development, that is first write a failing test after write the bare minimum code to pass the test then do refactoring. But it is ...
0
votes
1answer
83 views

when would you wrap a service object with an interface? [duplicate]

I'm new to UT and some of the best practices and anti-patterns when writing testable code, made me think. I used to wrap any service object with interface. but I see many mocking frameworks can ...
0
votes
0answers
54 views

when would you write static method as it avoid a “seam” for testing [duplicate]

when would you write static method. I used to write it in utils classes where all the methods are static and work state-lessly on arguments only. But now I know it blocks from creating a seam in ...
0
votes
1answer
93 views

Should I write a unit test to this?

Given the following pseudocode: List dohList = new List(); Foo foo = A.getFoo(); if ( foo != null ) { Bar bar = foo.getBar(); if ( bar != null ) { FooBar fb = bar.getFooBar(); ...
0
votes
0answers
99 views

Unit Testing: Pass in Modules or Entire Codebase?

In unit testing, the idea is (I think, correct me if I'm wrong) to unit test a module, then integration test these modules together, then integration test the respective "regions" of modules you ...
-1
votes
1answer
90 views

Do you spend your effort to reuse obsolete unit tests or rewrite them entirely? [closed]

I have this javascript project which has a unit test suite(about 200unit tests) that covers about 11.31% of the code that it was testing. The project has evolved greatly but the unit tests where never ...
0
votes
2answers
96 views

Introduction to testing [closed]

I am very new to the concept of testing and I had not yet have any experience with this. At my company, no one does write tests as of now, neither is any test framework set up or anything. Also, we ...
0
votes
1answer
42 views

Is there a cleaner way to test extras_require

I have code reviewed a piece of Python code, but to me it looks really ugly, hacky and complex for something that can be achieved very easily. The code looks something similar to the following: ...
0
votes
2answers
84 views

Handling repetitive unit testing tasks [duplicate]

This problem arose whilst writing a simple 3D vector class. The class contained methods (Java, so no operator overloading) for addition, subtraction, multiplication, and division. These methods ...
2
votes
1answer
217 views

Writing software without unit testing

Usually, when I write software, I use unit tests for each function to test if it is working without any problems. However, recently I have found myself writing some software that are not really ...
3
votes
6answers
456 views

Unit test private method in c++ using a friend class

I know that this is a debated practice, but let's suppose that this is the best option for me. I am wondering about what is the actual technique to do this. The approach that I see is this: 1) Make a ...
0
votes
0answers
50 views

Populate faked context for unit testing WPF ViewModels using entity framework

We're developing an entity framework based application which has about 20 different entities, with quite a lot of connections of various types (one-many, many-many etc) between them. Each entity also ...
10
votes
1answer
361 views

Does the games industry use automated testing for visual parts of games/rendering? How?

Some parts of a game are easy to test in an automated way (logic, maths, input handling); but there's also a lot that's purely visual and not easily testable. I would be surprised if the games ...
3
votes
4answers
254 views

Convincing my boss that touching the Database is integration testing [closed]

I am currently working on introducing continuous integration and switching to git, and as part of that, we must also better structure our tests. We have agreed on splitting the tests in "integration" ...
0
votes
2answers
114 views

Unit Testing large controller actions

I've a web page that has many constituent parts. On some user action, a POST operation is made, which then returns JSON to update the page. The problem is that this JSON payload contains a lot of ...
6
votes
3answers
790 views

How to unit test code that downloads a file from a github repo

This is my solution's structure: Storage.csproj > FileDownloader.cs > GitHubProvider.cs (implements IStorageProvider) > IStorageProvider.cs Storage.Test.csproj > ...
0
votes
2answers
109 views

Is a mocking framework useful if I'm unit testing a repository/database? [duplicate]

I'm trying to improve my testing skills. I frequently hear about mocking framework to build fake objects (as far as I understand). Right now I need to test my repository (the usual add, remove, update ...
0
votes
0answers
48 views

Mixing newable and injectable in a Callable

I recently read http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/ which discussed newable vs injectable objects. What would you do if you needed to make a Callable that talks to some service ...
24
votes
2answers
2k views

Unit testing classes that have online functionality

When unit testing functions of a class that has private functions that require online functionality. How would one go about testing it? For example: public class Foo { public int methodA() { ...
2
votes
2answers
83 views

Unit test database insert/remove and atomicity

I create my compact test database. This is a SDF file, embedded as a visual studio resource. When test suite starts this database is copied in %LOCALAPPDATA% so my test can use it. The first method ...
4
votes
4answers
313 views

Test-Driven Design is not Unit Testing [closed]

Ran across this statement by Martin Fowler circa 2002: Unit testing in XP is often unlike classical unit testing, because in XP you're usually not testing each unit in isolation. You're testing ...
10
votes
1answer
371 views

Testing strategy for games

I've inherited a web-based educational game. Over the past year I've worked towards stabilizing the code and adding new features. Most of the logic is in the front-end, so back-end unit tests, while ...
0
votes
0answers
45 views

Unit Testing an object which belongs to another

My example is in Rails/rspec, but is more generic in nature. I have an (abstract-y) class of Events which are attached to another (abstract-y) class, Assets (. Now, I'm testing using FactoryGirl and ...
1
vote
1answer
47 views

State Change Tests

In Chapter 3 of his book The Art of Unit Testing: with Examples in C#, Roy Osherove describes the concept of testing state change of a system. The example code under test he uses looks like this: ...
0
votes
3answers
91 views

Is it anti-pattern to mix unit test and web test? [duplicate]

It is a language agnostic question, e.g. I have a unit test like # Unit test User user = User.create('john'); assertEquals("User name is john", "john", user.getName()); # Web test start from here ...
2
votes
1answer
75 views

How to test generated file without hardcoding name generation logic?

I have a unit I'm testing which generates a file name and saves something there. I will need to pull the file out of that location to test it was stored right. I know how the file name is generated, ...
2
votes
2answers
44 views

Isolated Unit Tests and Fine Grained Failures

One of the reasons often given to write unit tests which mock out all dependencies and are thus completely isolated is to ensure that when a bug exists, only the unit tests for that bug will fail. ...
2
votes
6answers
266 views

Can unit tests verify software requirements?

I have often heard unit tests help programmers build confidence in their software. But is it enough for verifying that software requirements are met? I am losing confidence that software is working ...
1
vote
2answers
94 views

How best to construct our test subjects in unit tests?

Some of our business logic classes require quite a few dependencies (in our case 7-10). As such when we come to unit test these the creation become quite complex. In most tests these dependencies are ...
2
votes
4answers
214 views

How to refactor a myriad of similar classes

I'm faced with similar classes A1, A2, ..., A100. Believe it or not but yeah, there are roughly hundred classes that almost look the same. None of these classes are unit tested (of course ;-) ). Each ...
4
votes
2answers
130 views

Is it ok to write “extra” unit tests?

My understanding of how TDD should work is that you write a failing test for the next bit of functionality you want to add to a function or object, code until the test passes and then write the next ...
1
vote
1answer
71 views

Testing for Authentication loop holes / bugs

We've got a web application which is 99% complete prior to public beta, were currenlty securing the site from security perspective, locking down the server, db etc, one thing I'm concerned about but ...
0
votes
3answers
130 views

Is it actually worth unit-testing an API client?

This is something that's been troubling me for a while now. Is it actually worth unit-testing an API client? Let's say you're creating a small class to abstract-away the calls to a petshop REST API. ...
24
votes
6answers
2k views

Sense of unit tests without TDD

We have new (quite big) project starting, that we planned to develop using TDD. The idea of TDD failed (many business and non-business reasons), but right now we have a conversation - should we write ...
0
votes
2answers
70 views

how to write unit test for AND logic gate

I'm learning about unit tests, and have a doubt for a test i want to do, to implement an "AND" logic gate A B A^B 0 0 0 0 1 0 1 0 0 1 1 1 how can i test for a method that works ...
1
vote
2answers
101 views

Unit testing - should tests for a method validate the results of other methods?

One thing bothers me while I'm writing unit tests of my code. did tests of method should include validation of outcome from other methods? Of course, public methods. Let's go to - rather trivial - ...
2
votes
3answers
169 views

How important is automated testing in rapid release, non-critical (web) apps?

I think I understand the theoretical benefits of automated testing, especially unit testing. However, I'm not sure what the optimal amount of testing is when the project is a non-critical, rapidly ...
1
vote
1answer
182 views

Testing an MMO server

I'm working on a server for a very large (feature wise) MMO. After some bad experiences with breaking changes that caused bugs weeks down the line, we'd like to add unit/automated/regression tests to ...