Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.
0
votes
0answers
42 views
Algorithm / Coordinator or Worker / Integrator Distinction
In this article by Jakub Holý on writing maintainable and evolvable tests, the author shares his experience of a course lectured by Kent Beck and that when designing a part of the system Kent would ...
6
votes
3answers
617 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
70 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
40 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 ...
23
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
73 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
286 views
Test-Driven Design is not Unit Testing [on hold]
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
329 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
44 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 ...
0
votes
0answers
43 views
Mocks and Stubs - Classes and methods? [duplicate]
I'm trying to get a high level understanding of mocks and stubs.
My language/frameworks are ruby, rails, rspec, jasmine
I heard this very high level definition:
Mocks are used to represent objects ...
1
vote
1answer
46 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
83 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
70 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
42 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
241 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
89 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
207 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
114 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
68 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
94 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
66 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
96 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
157 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
174 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 ...
0
votes
0answers
49 views
Run RSpec from within a ruby script while refreshing all ruby configs etc
I'm working with a very large project with tons of established tests that include some reasonably complicated environment setups and what not. I've recently run into a situation testing some ...
0
votes
4answers
142 views
Should each method have a seperate JUnit test class?
I am writing JUnit unit tests for my classes.
Is it better to have a separate class for each method, or have just one test class for every actual class?
2
votes
2answers
92 views
Should we test the values of objects returned from the methods being unit tested?
Being new to unit testing I would like to know if I am supposed to test the values of objects returned from methods when doing unit testing. As an example, consider the following classes:
public ...
4
votes
3answers
217 views
What is the best use case for selenium?
I've been trying to develop web applications while at the same time creating the testing. I understand unit testing, I can declare a test method and test specific methods in my application.
But I ...
1
vote
1answer
192 views
Which is the more testable C function implementation?
I write code in C. I have been striving to write more testable code but I am a little
confused on deciding between writing pure functions that are really good for testing
but require smaller functions ...
4
votes
2answers
219 views
Am I doing TDD wrong when multiple tests can fail for the same reason?
Assume a method with the following declaration
public IList<Location> GetLocations() { ... }
I write (at least) the following tests
Check to see if the method returns an empty collection if ...
8
votes
2answers
178 views
Test Driven Development for Complex Games
I'm coding a game in my spare time, but I am mostly still a beginner when it comes to programming. I'm sorry if this question is off topic or if it ends up not being helpful to anyone else, but ...
2
votes
3answers
64 views
Unit testing statically loaded data
Scenario: I have a configuration file containing some structured data that is loaded in at runtime and is not modified by the application, but is referenced in many places. There are functions that ...
3
votes
4answers
180 views
How to identify and run the most relevant automated tests?
Suppose you have a reasonably large codebase (0.5 - 1 msloc) with a large test-suite (6-7hr single-threaded runtime; with a mix of unit-tests and integration-tests built with different tools). You ...
0
votes
1answer
179 views
Is testability and mockability really that important in web development?
I'm reading this series on Laravel, and it's in great depth dealing with making everything testable, using Repository instead of just using the Models, using Dependency Injection and other obscure ...
1
vote
1answer
51 views
Testing Facades, Is it a good idea?
I stumbled across a need to create a thin I/O Layer interface to abstract away a class from the need to know about I/O
public interface IFileIOProvider {
Task WriteFileAsync(String contents, ...
3
votes
1answer
86 views
Testing gap between unit and integration: Integration in the Small, Component, Unit Integration Tests
Over the past few weeks I've been mulling and researching how to fill a gap in our testing methodology. In simplified terms unit tests are too small and traditional integration tests are too big.
A ...
28
votes
6answers
3k views
Why isn't testing a language a supported feature at the syntax level?
You can find an endless list of blogs, articles and websites promoting the benefits of unit testing your source code. It's almost guaranteed that the developers who programmed the compilers for Java, ...
17
votes
4answers
807 views
How can I use unit tests and TDD to test an app that relies mostly on database CRUD operations?
At work, one of my projects is mostly about taking data passed in from an external client and persisting it in a database. It's a Java enterprise app using JPA and most of our logic revolves around ...
0
votes
3answers
203 views
How should I test boolean function with many possible permutations
When I write an unit test I usually provide a context (plain object or mocked/stubbed object) that I setup in some ways and then I can run assert statement on the context:
note: code is in ...
12
votes
7answers
526 views
Coding and testing in the same sprint
How is testing handled within the same sprint as coding, if all or most of the coding is not done until the end of the sprint? (I'm referring to the "soup-to-nuts" development and testing of a single ...
-1
votes
1answer
120 views
Approach to cover all the cases in Unit Tests [duplicate]
I am new to Unit Testing and i am able to write them but my problem is I am not sure that I have covered everything in Unit Tests. What could be the approach for testing some functionality in a code?
0
votes
1answer
135 views
In an enterprise setting, does one apply BDD principles alongside of, or instead of, “traditional” unit testing?
I have a problem visualising how the gap is closed between coarse-grained, n-tier boundary, high level, automated acceptance testing and lower level, task/sub-task scope Unit Testing.
My motivation ...
4
votes
3answers
211 views
How should I unit test a bitmap modifying method?
My Sprite class has a method:
private void updateWithBitmap(Bitmap b, int x, int y)
This will 'lay on top' the bitmap that's passed in, the top left corner of the passed in bitmap being at the x,y ...
2
votes
2answers
94 views
Should “tests” be kept out of the main merge pipeline?
We all know sometimes a e.g. merge can go wrong.
If our [unit / integration] tests are in the same repository as the merge, is there then a weakness there that if the tests have merged incorrectly ...
4
votes
2answers
159 views
Unit testing - one test is partly a “superset” of another, is this wrong?
Wasn't sure how to phrase that title, sorry!
I've just come across this in our code base, and was wondering what the consensus was about how to unit test it:
C# (-ish, sorry, this is paraphrased ...
4
votes
2answers
249 views
What kind of code would Kent Beck avoid unit testing? [duplicate]
I've been watching a few of the Is TDD Dead? talks on youtube, and one of the things that surprised me is Kent Beck seems to acknowledge that there are just some kinds of programs that aren't worth ...
1
vote
2answers
68 views
Creating an Interface To a Language's Standard Library?
In the process of learning test-driven development, I've been introduced to dependency injection and the use of interfaces, and have started using these concepts in my own PHP code in order to make it ...
0
votes
1answer
133 views
Your thoughts on Best Practices for Scientific Computing? [closed]
A recent paper by Wilson et al (2014) pointed out 24 Best Practices for scientific programming. It's worth to have a look. I would like to hear opinions about these points from experienced programmers ...
0
votes
1answer
102 views
Is the test, which touches the filenames under directory, a kind of unittest? [closed]
I was told that unittest is fast and the tests which touches DB, across network, and touches FileSystem are not unittest.
In one of my testcases, its input are the file names (amount about 300~400) ...