Most voted "unit-testing" questions
Unit testing or unit testing is a method by which individual source code units, assemblies of one or more computer program modules, together with associated control data, operating procedures and operating procedures, are tested to determine if they are fit for use.
Learn more…165 questions
Sort by count of
-
41
votes2
answers3902
viewsTests, TDD, Unit Test, QA and similar. What is the difference between concepts about tests?
In the question of the goal 5 different tags for "testing" I noticed that I have some difficulty understanding all these terms about tests. Certainly tests have been very important throughout the…
testing software-engineering unit-testing tdd functional-testingasked 10 years, 5 months ago Maniero 444,682 -
35
votes2
answers9074
viewsWhat is the difference between mock & stub?
In what situations should be used? What’s the difference between them?
-
27
votes3
answers1491
viewsStrategies to prevent software regression
What programming strategies/best practices can be adopted to minimize the risk of software regression? Questions that can help guide: which "pranks"/bad practices can fool the programmer and leave a…
-
26
votes2
answers1684
viewsWhat are Unit Tests for and what are the advantages?
I saw some videos and articles on unit testing, learned the Qunit framework and some test situations. Still I could not think of a practical use that is worth more than a common browser debugging or…
-
20
votes1
answer200
viewsHow to make a test fail if it takes too long?
I’m using Mstest which is the default drive testing platform in visual studio and have this test here: [TestMethod] [ExpectedException(typeof(InvalidOperationException))] public void…
-
15
votes3
answers2138
viewsHow to perform unit tests on nodejs
I’d like to run unit tests on Node.js, I’m using the grunt-jasmine, but it does not recognize the variable exports, module and neither required. Is there a way to solve this or does someone suggest…
-
12
votes1
answer191
viewsIs it correct for a method to make the same exception for two different reasons?
I’m practicing TDD simulating an alarm system. Alarm centers work connected to sensors that detect intrusion (opening a door or window, or movement within a room, for example). They have a fixed…
-
9
votes1
answer766
viewsWrite unit tests for the interface or for the implementation?
Given the following test scenario, where I have the interface: public interface UserService { /** * Registra um usuário no sistema. * * @param user * Usuário à ser registrado. Não deve ser {@code…
-
9
votes2
answers967
viewsHow to test private methods in C#?
How to test private methods using Microsoft.VisualStudio.Testtools.Unittesting and Moq My test class is like this: [TestClass] public class ClasseDeTeste { private MinhaClasseComMetodosPrivados…
-
9
votes2
answers2071
viewsWhen to use static methods mock?
@Fernandoschelb recently asked the question about how to mock static methods. It raised my doubts: If we can do it, when we should do it? What are the cases where static method mock is beneficial?…
-
9
votes1
answer349
viewsIs unit testing a generic term? What types are there? And what ways to apply?
Unit testing is a generic term for any test of an independent part of a program? Or is it a exclusive term for object-oriented paradigms, with procedures already known? Every time I find any post…
-
8
votes3
answers2543
viewsUnit test with database
I have an application that uses JPA 2 with Hibernate behind and for unit testing, I use HSQLDB in memory with Junit 4.11. HSQLDB is configured in a persistence.xml file in a META-INF folder. My…
-
8
votes1
answer140
viewsPremises for a testable software
Based on development in object-oriented language, what would be the premises for software to have robust testability (coverage and testing facility) ?
-
8
votes1
answer1510
viewsIs there any way to test a route using PHP Unit in Laravel?
I love to create using the PHPunit to create unit tests for my libraries. Always, before doing the git commit, run it to see if any changes affected what was previously working. I wish I could also…
-
8
votes1
answer557
viewsTDD and Unit Test, both are the same thing and have the same purpose?
Always when I read about TDD (Test Driven Development) it is related to Unit test, It makes me believe that TDD is the same as Unit test, and I don’t know if my definition is correct in relation to…
-
8
votes1
answer101
viewsPros and cons of securing an interface contract through a subclass
This article presents an interface IList<T> containing the methods Add(T item) and Count(). The contract of that interface expects that when an item is added, the method Count() reflects the…
-
7
votes2
answers736
viewsWhat is the advantage of using Junit to test methods in a class?
I created an application that is basically a class that tests if the methods of another class are returning the expected values. My teacher asked me to remake this class as a Junit test case. I did…
-
6
votes2
answers944
viewsMock Static method with Demoiselle and Powermock/Mockito
I’m trying to mock a Static method, but Powermock requires the use of a specific Runner (Powermockrunner) for the Static mock to work! And for Demoiselle to work, you need to start Weld with…
-
6
votes1
answer623
viewsIs there any way to do an PSA unit test?
I am in need of a help to do ASP unit testing for a software quality project. It is possible to do this? Remembering that it is classic ASP.
-
6
votes1
answer56
viewsObject state invariance check between private methods execution
In this reply to the question How to test private methods in C#? is referred to The maximum that can be interesting is to have an object state invariance check between the execution of private…
-
5
votes1
answer1942
viewsError when running test project
I added a test project to my Solution to test the methods of my MVC application. I created a base class, for the other classes with tests to inherit from it, which contains context creation…
-
4
votes1
answer2094
viewsHow do I set up Netbeans to work with Phpunit in a virtualized environment?
I use Netbeans 7.4 for programming on my Mac. And to not have to install PHP and Phpunit, I would like to run Phpunit installed on a virtual machine that has an entire integration environment…
-
4
votes3
answers1665
viewsTest automation on web pages
I would like the indication of tools to record the data entry on the page. I have already used the Selenium IDE, Selenium Web Driver. I saw that there is the iMacros. I am programming in JSF, Java…
-
4
votes1
answer1064
viewsUnit tests on Android
How to test unit on Android? How far I searched is only possible to use the framework Robotium. There is another way to test unit on Android?…
-
4
votes1
answer210
viewsRuby on Rails boot time
In Ruby on Rails, using the Minitest library, the test run time is fast. But the boot time before each rake test (...) is pretty annoying. Is there any way to make it faster? Updating I tried to…
-
4
votes1
answer201
viewsProblems running only one unit test on Rails 4
When I run all the tests or just tests a file is working normally, but when I try to run just one test, it just doesn’t run. I have this test require 'test_helper' class UserTest <…
-
4
votes2
answers668
viewsDoubts about unitary tests
I am new to unitary testing and am in doubt in some basic applications. First: the focus of phpunit is to check if a return has an expected pattern. If yes, the test has passed. If not, it throws…
-
4
votes1
answer1107
viewsUnit test of implementations of a Generic class
Suppose we have the following interface: public interface ICRUDService<T> { T Create(T entity); } Abstract implementation: public abstract class CrudService<T> : ICRUDService<T> {…
-
4
votes1
answer123
viewsWhen to do unit tests in Javascript?
As far as it is advantageous to do unit testing in the presentation layer, and, what would be the scenarios where unit testing in Javascript is advantageous? Only advantageous if you have…
-
4
votes1
answer242
viewsIs testing the interaction with html and Javascript using Jasmine wrong?
Javascript code has some interactions with html like this example: function retornaListaDeItens(argument) { return document.getElementsByClassName(argument); } I use the return of this function to…
-
4
votes3
answers404
viewsHow do you test something "unstoppable"?
Testing certain components of a system is simple if that component does not have very relevant dependencies, such as a class like this: public class Data { private final String _field; public…
-
4
votes2
answers95
viewsWhat is the best way to define access to the methods of a class I want to use for unit testing?
I have a class Runnable, that does a lot of things in my system. When I created it, I didn’t want to instantiate its methods out of her scope. That’s why I wrote the methods like protected. Now, I’m…
-
4
votes2
answers2567
viewsJunit Eclipse Error: "No test found with test Runner Junit 5"
I’m not being able to run my tests in Eclipse, below is a simple test that doesn’t work: import org.junit.Assert; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; class…
-
3
votes3
answers5014
viewsTesting a void method with mockito
How to test a void method with mockito? This is the basic syntax for a return method when(Classe.metodo()).thenReturn(variavelRetorno); However, how do I test a void method?…
-
3
votes1
answer1776
viewsUnit test/ Mock of a JPA query
Hello, how do I generate a unit/mock test of a JPA/Criteria query ? What can I guarantee by mocking my objects? Table structure? What should I mock? The consultation is very simple, only one select…
-
3
votes1
answer471
viewsIs it possible to run class unit test with inheritance?
I need to do a unit test of PlanilhaReader but this extension ArrayList<String> and override the method contains. Is there any way to execute it? @Component public class PlanilhaReader extends…
-
3
votes1
answer224
viewsHow to implement unit tests for Clipper?
I have a legacy system developed in Clipper, an old programming language, similar to C and which had discontinued support for at least 20 years, being maintained until today by the project xHarbour,…
-
3
votes1
answer915
viewsTest classes with dependencies (C# + Entity Framework)
I have a class "Sell" (summary of the class below) and in it I have a property "Orcamento". What would be the best way to do a unit test in this class? I came across 2 problems: Mock frameworks…
-
3
votes1
answer201
viewsError accessing dao class by test class
I have the following error, when accessing a dao class of a test class: java.lang.Nullpointerexception This is the controller method: @Post("/consultar_lancamento/{codLancamento}") public int…
-
3
votes2
answers782
viewsHow to use JUNIT to test void methods of my DAO class
Hello I have a DAO class and I want to implement tests with JUNIT, but many of the methods have the return void. Here’s a piece of the class that makes up the DAO package public class ExemplarDAO {…
-
3
votes1
answer173
viewsHow to Refactor Legacy JS to Implement Unit Tests?
I have a Wordpress site with many JS files that have not been structured to be tested - they have not been written as modules that can be imported nor is there a app.js that loads them all as a…
javascript unit-testing refactoring jasmine jestasked 6 years, 4 months ago Ricardo Moraleida 4,005 -
3
votes2
answers406
viewsWhat is the purpose of the Interfaces used in a Mock?
I’m using a library called Moq which serves to create mocks that will be used in unit tests. However, to create a mock it is necessary to specify an interface, as in the example of the Moq project…
-
2
votes1
answer60
viewsAndroid Test - Call Method
I wonder if in android Unit test would have the possibility to call isolated methods of code, or if only calling activitys, buttons... I searched several places and found nothing talking about…
-
2
votes0
answers64
viewsUsing Moq with MVC Dotnet
I am using MVC4 with Moq and would like to know how to mock mine Model also and if this is possible. Thank you.
-
2
votes1
answer527
viewsDelphi Unit Test
I am implementing Dunit in the company and my question is the following: there is some way to click the button of a "Showmessage", of a form I can, but I would like when the showmessage window…
-
2
votes1
answer137
viewsIs it advisable to write automated tests for the user interface?
When it comes to unit tests and TDD, we usually think of so-called "business logic" tests, which are based on requirements, etc. But we also find on the web examples of tests of the user interface,…
-
2
votes2
answers5233
viewsHow can I test method with void return using Junit?
It is possible to perform automated testing, in Java, of a method that has return void using JUnit? If yes, how is it possible?
-
2
votes0
answers60
viewsHow to configure schema_search_path in the test environment?
When I run the rake spec --trace command I have the error below. It seems to me that rake does not create the schema I want in the test environment by not identifying my schema configuration in…
-
2
votes1
answer863
viewsModel attribute unit tests in spring boot application
Good afternoon I don’t have much experience with unit testing. I’m testing controllers in a spring boot application, but I made some error in testing model attributes, which apparently isn’t even…
-
2
votes1
answer184
viewsPhpunit not recognized by Cakephp
Now with the discontinuation of Phpunit support by Pear, I started to face a big problem to make Cakephp recognize Phpunit... Phpunit is already installed on my computer (Linux Mint), I can use it…