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
9 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
54 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
363 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
43 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
92 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
77 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
82 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
220 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
158 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
167 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
151 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
62 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
207 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
93 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
65 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 ...
0
votes
0answers
41 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
278 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
268 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
125 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
181 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
50 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
63 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
103 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
61 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
123 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
567 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
340 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
334 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
166 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 ...
2
votes
2answers
350 views
should I test this public method
I have the following simple implementation:
var VALIDATION_TYPES = {
ERROR: 1,
WARNING: 2
};
var validationRules = {};
this.addErrorRule = function (event, rule) {
...
2
votes
2answers
168 views
When testing is it OK to use a method of the subject to test another method of the subject? [duplicate]
I have two methods in the same helper class one that creates an image (method A) and one that compares two images (method B).
I want to check the return of method A against an existing image. To do ...
1
vote
2answers
200 views
How to add rigor to my testing?
I work on a small/medium sized Java application. Over time, I've tried to ensure that the tests which I write are "good" tests, and that there's plenty of them. Hence I've been looking into various, ...
-1
votes
2answers
196 views
Scheduling a Jenkins job to only run integration test [closed]
My current company has a Jenkins/DotCi setup. Our current process for CI is when dev pushes to github, jenkins runs unit tests on all branches and reports back to us via email if the unit tests ...
10
votes
4answers
1k views
Is there any value in writing a unit test that is a subset of another test?
To give a slightly contrived example, let's say I want to test that a function returns two numbers, and that the first one is smaller than the second one:
def test_length():
result = ...
0
votes
1answer
117 views
Testing - How to test if you are actually testing the code?
I was thinking about unit tests and code coverage, and I came up with this thought:
It is possible to have 100% code coverage and not test 100% of your code.
For example:
function ...
0
votes
1answer
49 views
Testing - Test for Specific Paths?
When (unit) testing, is is bad to expect the code to use certain paths.
For example, should I be testing for specifically "/build/static/public/css/", or just that server.cssPath has been set to a ...
12
votes
4answers
1k views
This way I'm writing this code is testable, but is there something wrong with it I'm missing?
I have an interface called IContext. For the purposes of this it doesn't really matter what's it does except the following:
T GetService<T>();
What this method does is look at the current DI ...
1
vote
1answer
231 views
How to write unit tests for a piece of code that has a data context?
I am new to unit testing and using Microsoft's unit testing library for following piece of code. When I execute the code normally it executes fine, however when I run unit test written for this code I ...
3
votes
1answer
127 views
Unit testing a template class after refactoring
I am cleaning up my code by way of removing duplicates, and found two classes that were almost identical, out of 55 lines, only a single predicate in an if statement differed between them.
Both ...
3
votes
1answer
83 views
Where does test fixture code fit in?
This is an unusual question since I don't believe it lends itself to typical software development practices but I hope you can prove me wrong.
In MATLAB, my team have created several signal ...
7
votes
2answers
293 views
How do I unit test a heuristic algorithm?
Say we have our route finding algorithm:
def myHeuristicTSP(graph):
/*implementation*/
return route
Now we want to unit test this:
class TestMyHeuristicTSP:
def ...
2
votes
0answers
109 views
How to test network connectivity API using TDD?
I'm currently trying to add TDD on my workflow. I fail to create tests where I can easily test a library that requires remote connections.
More precise, my program uses snmp4j library. Currently I'm ...
-1
votes
1answer
65 views
Starting a big application with unit testing [closed]
I am learning test driven develeopment and read some books about TDD. I learned rules of unit testing. How can I write unit test, how can I select test method names, Act, Assert, Action and like this. ...
0
votes
2answers
230 views
Workaround for unit testing Core Data in Swift
I am still pretty new to programming, but my first app was recently approved and is now for sale on the App Store. My app uses Core Data and is written in Swift. After some initial difficulties, I ...
3
votes
5answers
209 views
How do you unit test a function that clears properties?
I have a very common function that I have always unit tested in the same way, but I'm wondering if there is a better solution or if it's even possible a code smell is involved. It seems like a very ...
2
votes
2answers
269 views
Unit testing and reality [closed]
I m actually studying Unit testing, reading some articles on the internet and trying to understand how it works exactly, but it's not very clear for me actually.
What should I test ?
I have seen ...
4
votes
3answers
149 views
Test Driven Development when the specifications change
These days, it's fairly common for me to be tasked to make a change that actually breaks the prior spec. I know that one of the major ideas behind TDD is to have a suite that verifies all your changes ...
1
vote
1answer
65 views
Java Unit testing multiple test cases in one test [duplicate]
Is it good practice to have multiple test cases in one test or should I always create one test for single test case in every situation even if it is redundant? Why?
5
votes
1answer
143 views
How do you unit-test code using graphs?
I am writing (recursive) code that is navigating a dependency graph looks for cycles or contradictions in the dependencies. However, I am not sure how to approach unit testing this. The problem is ...