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
0answers
32 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
78 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
52 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
89 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
46 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
38 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
2k 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
2k 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
136 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
578 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
50 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 ...
0
votes
1answer
65 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 ...
-3
votes
0answers
36 views

how to test django app using mock and unittest [duplicate]

I have a question on testing django app using unittest and mock python library. I am taking a web design class this semester and we need to work in group to make a website for the class project. My ...
5
votes
4answers
934 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 ...
-1
votes
1answer
64 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
50 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
256 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
135 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
56 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
202 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
38 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
69 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
435 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
1answer
75 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
168 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
84 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
92 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
242 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
208 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
185 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
170 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
72 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
226 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
106 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
99 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
77 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
288 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 ...
6
votes
5answers
295 views

How should I unit test mathematical formulae?

I have a number of functions that are pretty close to the mathematical definition of a function. For example, a simplified version of one of these functions may look like: int function foo(int a, int ...
4
votes
6answers
138 views

How do you check that code has been covered automatically?

I am in the process of setting up a Bamboo server for some new projects for a push to TDD in a CI/CD workflow. Sure, unit testing is great, but only as log as it is there. Now this might be better ...
0
votes
6answers
189 views

Cheap implementations in fundamental TDD

This is a question concerning the fundamental approach of TDD, so the example below is as simple as possible which might make it seem a little useless; but of course the question applies to more ...
0
votes
2answers
58 views

How to add cases to large legacy code base project? [duplicate]

There is a legacy project full of C++ code. As a MFC GUI project, it contains lots of businesses logic out of control and beyond average level programmer to understand. To work on such GUI project, is ...
0
votes
1answer
99 views

MockRepository vs Test Database for Unit Testing

Before starting, this question is not the same as this one. Comming from a PHP background, my experience is in CakePHP, which is a framework that supports Unit Testing by setting up a local test ...
3
votes
1answer
154 views

How do you write tests for methods that interact with data in system files?

I'm trying to be proactive about writing an iOS app in a test-driven manner. However, I'm stumped as to how to test a method that is to interact with real system files. For those familiar with iOS, ...
0
votes
1answer
63 views

Beginner's UnitTests for MVP Presenter class

In my application, I have a user settings form with roughly 20 checkboxes and a few other controls. The checked state, enabled state and texts of these controls are bound to about 60 properties of the ...
1
vote
3answers
175 views

What does stubbing mean in programming?

I often hear the term stub, stub out somethings, stubs, ...etc. What does stubbing mean in programming, where the word come from? and in what contexts it can be used?(just examples)
5
votes
4answers
591 views

How to test a method which is not as much as a unit, because it is more of a 'orchestrator' / 'process' / 'controller' / 'coordination' class [duplicate]

I want to test a method which is not as much as a unit, because it is more of a 'orchestrator' / 'process' / 'controller' / 'coordination' class. This is the case: I have four unit tested classes: ...
6
votes
2answers
346 views

Small code, big test

I have this code in a controller of an MVC implementation: public void execute() { try { String path = userSelectsFile(); if ( path == null ) return; //Just returns ...
8
votes
2answers
352 views

How much logic can be put into a command? Or differently: What kind of logic is command pattern for?

I have been using the command pattern for quite some time but I'm never really sure how much logic I can actually put in the Execute method. My current implementation of the command pattern looks ...
0
votes
2answers
182 views

Which language has most advanced support for proof based programming? [closed]

By proof based programming, I mean, you can somehow prove the correctness of your program without testing. I heard that Ada has a feature called contract, I also heard that, if you can pass Haskell's ...