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)

3
votes
2answers
115 views

Domain object model: query by id vs object

Let assume I have two simple model classes: Product and Brand It is obvious I have a query method in Product class like this Product product = Product.findById(123); What if, I want to query ...
-3
votes
0answers
20 views

Good code resource to learning database interaction [closed]

I am currently working on project with MySQL database and I am looking for good practices to working with database in Python. The next problem I have is that I want to start with unit testing ...
2
votes
2answers
140 views

Example of writing unit test for a method

I am writing unit tests for an iOS application. I clearly understand the benefits of writing unit tests & TDD, but I am confused about what kind of tests you can write for methods like this; ...
6
votes
3answers
179 views

Advantage/Disadvantage of having all variables declared in a JUnit Test

I've been writing some unit tests for some new code at work, and sent it off for a code review. One of my co-workers made a comment about why I was putting variables that are used in a number of those ...
1
vote
5answers
113 views

Unit-testing on higher levels of architecture

tl;dr: Libraries and classes I use as client are well tested. How I can use that knowledge to reduce amount of testing? Elaboration: Let's assume for theoretical purposes that we're implementing ...
3
votes
1answer
93 views

Is contructing complex mocks for unit testing a sign of bad architecture?

The title is fairly self explanatory. To elaborate: I'm currently updating a suite of unit tests for an application which makes heavy use of Entity Framework. We connect to this via a classic ...
0
votes
2answers
41 views

Testing binary stream

I am building a binary file importer using Python. The specific file structure is defined in a specification. This looks like: File Map Block String, Short Integer, Long Integer, String, Short ...
0
votes
2answers
48 views

Defects Review and Management

The doubt or question i have is something every developer might be facing time to time. it is related to testing and development team and their perspective. I have observed that most of the Defects ...
1
vote
5answers
250 views

Are mocks in unit tests dangerous in dynamic languages?

I've started relying heavily on a mocking framework in php for my unit tests. My concern is that with a dynamic language, there is no way of enforcing a return type. When mocking, you have to ensure ...
4
votes
1answer
71 views

Cons of using unconstrained frameworks for unit testing

It's very easy to write unit tests for legacy code using unconstrained frameworks, such as TypeMock Isolator. But what about writing unit tests for newly written code? Is it a good practice to use an ...
1
vote
2answers
151 views

How to unit test static void methods? [duplicate]

How does one go about unit testing static void methods? I have a few more questions: Is it necessary to unit test database queries like insert, select and update queries ? If so, how does one test ...
3
votes
1answer
133 views

How well am I writing my tests?

I've been coding as a career for about 2 years now but am just now writing my first "real" tests for a non-trivial application. I've been trying to follow best practices I've picked up from the ...
3
votes
5answers
184 views

Injecting collections as constructor dependencies

We are using constructor dependency injection in our application. Following that approach we inject everything using an injection container so we are able to replace any dependency with a Mock. Some ...
0
votes
0answers
34 views

Unit testing : verifying calls : is it a good practice for non-logic code? [duplicate]

I'm currently working on a Java project where many of our services simply call adapters, with no particular business logic. In the most extreme cases, the code of the service is simply return ...
0
votes
1answer
102 views

How do I actually use Selenium to automate UI testing? [closed]

We have a large inventory system where we work and making changes has the possibility to break things in other areas. This happens a lot, and it is hard to manually test for everything every time ...
1
vote
2answers
54 views

Verifying absence of an event in multithreaded unit test

I've got a legacy application that had a fragile unit test (which is really more of an integration test) that used a lot of Thread.Sleep calls to wait for events to happen. While trying to introduce ...
1
vote
1answer
100 views

How to unit test a top level method

I'm trying to unit test a small program I wrote. My problem is that I can't see an easy way to unit test my top level class (Matcher) that exposes a single public method (MatchAll). I do have tests ...
2
votes
1answer
49 views

How to unit test logic in crud app

Apologies if this question has been asked before, I've seen similar questions, but nothing quite the same. I am writing a web application which uses http calls to write and read from a back end ...
0
votes
0answers
64 views

DBUnit alternatives to test DAO layer

We have a lot of DAO tests written with DBUnit and (it's ugly) datasoure. It's not that hard to edit it and add some new entries but it's annoying. Worse is that we have only one datasource for all ...
6
votes
2answers
1k views

Is “Unit testing” a form of formal method?

After some research, I understand that: Formal method contribute to the reliability and robustness of a design. (ref : Wikipedia - Formal method) Unit testing ensures us of the absence of errors ...
10
votes
4answers
5k views

Should one use Dependency Injection even if the class is used only once? [duplicate]

During a code review I have started having a bit of a dilemma as to whether use dependency injection or not. I would like to hear your thoughts, because this is kind of an ongoing theme and would help ...
2
votes
2answers
154 views

Unit testing and reusing extracted class

Currently I have 3 service classes, they all have a similar pattern, and I need to make a 4th service class which amalgamates the functionality of the other three. Current three classes public class ...
6
votes
6answers
600 views

Why are my unit tests so expensive? [duplicate]

I am a Java developer, working on a small project. We are three people in the team, we have a budget for 3 months of coding (+ some time for the Analyst, Project Manager and QA team). It is a small ...
0
votes
0answers
58 views

Abstract Web API from validation and configuration management in embedded system

Im working with embedded Linux for a router. There is a web GUI for the user to configure router options. When user fill a web form this is submitted to a web server function that is responsible of ...
2
votes
2answers
109 views

How do you unit test \ use TDD methods for ETL's and reporting projects?

ETL projects are projects created using an ETL (Extract - Transform - Load) tool such as SSIS, PowerCenter,etc These typically involve reading data from an external source, loading it to a staging ...
5
votes
4answers
956 views

Is it a bad practice to separate the unit tests for a class? [closed]

My Classes normally have about 5-20 methods maximum, that implies that the class that has the unit tests has about the double of methods (counting dataProviders, setUp, ...) I have thought to ...
0
votes
1answer
170 views

How to test model binding within an MVC controller when Bind attribute with Include list is used?

Auto-generated action methods in MVC5 make use of the BindAttribute with an Include list that contains the field names in a string literal. Example: // POST: MyTable/Edit/5 // To protect from ...
1
vote
2answers
51 views

Global / Application settings and testing

We have a global dictionary of application settings (read from a DB on start-up and refreshed when required) and a static class with a bunch of methods to get these settings. This is historic, but I ...
6
votes
3answers
264 views

Implementing common logic in base class

Background In the documentation of a project I'm working on I came across the following sentence which immediately triggered an alarm for me: when having several concrete classes that inherits ...
2
votes
3answers
138 views

Unit Testing and dependencies

I'm just learning how to do proper unit testing, and a lot of resources make reference to using explicit dependencies, ie dependencies that are passed into the constructor, to allow for easy ...
0
votes
1answer
59 views

Test logic with external data [duplicate]

I have a site programmed in PHP where I make more call to external server that return me big xml of data. For each record of the xml I have to make other external call to get other data. So my ...
4
votes
4answers
229 views

Filling the gap between Conception and Unit Test

I am stuck trying to do TDD. I'd rather seek the counsel of others who have gone before rather than waste time with trial and error. QUESTION: What diagrams / exercises / development processes can ...
0
votes
0answers
48 views

How to handle karma/bower in a Symfony Bundle on github?

i am working on a Symfony Bundle that uses angular among other javascript deps. Now i want to unit-test my javascript code and i want to ship those tests as well. My initial idea was to add ...
2
votes
2answers
72 views

Value of unit testing property setters to check events [duplicate]

When coding in WPF with the MVVM pattern, it's common to see a lot of property get/set statements that raise an event, which can then be picked up by the UI layer. public string Address { ...
5
votes
3answers
464 views

Is Functional Programming a viable alternative to dependency injection patterns?

I have recently been reading a book entitled Functional Programming in C# and it occurs to me that the immutable and stateless nature of functional programming accomplishes similar outcomes to ...
1
vote
2answers
121 views

Testing front-end app that hits a REST service

A lot of questions about testing here... And I have another one. Forgive me, but I want to make sure I do this right. Let's say I have a front-end application, be it a mobile app, or a single-page ...
0
votes
2answers
207 views

how does test-driven development prevent us from type errors?

I heard (from Robert C. Martin) an assertion that since dynamic languages don't have static typechecking, people should write unit tests to prevent us from type errors. I'm not sure if I'm following ...
0
votes
2answers
85 views

How to ensure a new Unit Test is for the correct Test Case? [duplicate]

When writing a unit test for a scenario believed to be already covered, ie, the first run of the test would be green, what is a good guideline to ensure that it is in fact testing the proper test ...
-1
votes
5answers
93 views

Skillset for unit-testing [closed]

I have two questions regarding this topic: How long does it take for you to create unit-tests? Take a project for a web-application, and you are working TDD. How long time does it take for you to ...
7
votes
4answers
1k views

Is it bad practice to make methods public solely for the sake of unit testing? [duplicate]

I have a class with a public method. It has other methods that 'assist' with the purpose of the public method. The public method must be tested. However, I also want to unit test the private methods. ...
1
vote
4answers
249 views

How to make one test depend on the results of another test?

Let's say there is a utility class that provides some common static methods used everywhere in your code by many other classes. How would you design your unit tests for the consumers of the utility ...
5
votes
3answers
280 views

How to use unit tests when using BDD?

I am trying to understand BDD. I've read some articles and as I understood BDD is "the next step" from TDD. I say that because I find both to be very similar, and as I could read in this article, BDD ...
5
votes
4answers
216 views

How to unit test correct implementation of an interface is used?

I have this problem with unit testing for years. Unit testing should test isolated units, that is, if we use interface/implementation vocabulary, it should test concrete implementation classes. Fine, ...
3
votes
1answer
184 views

Why the practice of writing unit tests in a different language isn't that popular?

When Microsoft released Visual Studio 2008, there was a thing they were talking a lot about at the conferences and in their online tutorials: the idea of writing the actual code in one language, and ...
1
vote
1answer
76 views

how to unittest with thorough test coverage [duplicate]

I am trying to get into unit testing with python (though my question is not specific to python). I want to add a test for function I already have - I know I should do it the other way round, but here ...
4
votes
2answers
238 views

Is checking that a property doesn't throw an exception a valid unit test?

I'm writing tests for the following class: public class Foo : INotifyPropertyChanged { private int _failCount; private int _totalCount; public double FailRate { get { double ...
0
votes
3answers
109 views

Should all possible counter-cases be tested? [duplicate]

I'm currently trying to unit test a behavior which, in some very particular cases, returns B instead of A. It may depend on the value of 3 different attributes for example. How should I test this? ...
0
votes
1answer
102 views

Testing process on life critical systems [duplicate]

I currently work in web development - unit testing, functional testing are all good and really are part of what is considered being a professional developer. However, I also have a fear of flying and ...
2
votes
0answers
107 views

Unit testing Eloquent outside of Laravel

How can I unit test my Eloquent models when I'm using the ORM outside of Laravel? What I'm hoping to do it run tests on each model but somehow mock the database connection/query/builder(?) object. ...
5
votes
1answer
294 views

Should the expected value be hard-coded into the Assert

My own personal preference would be to use a variable, but maybe there are reasons against this? I haven't been able to find any resources that state the pros or cons of using one of these over the ...