Skip to main content

All Questions

Tagged with
963 votes
31 answers
555k views

Unit Testing C Code [closed]

I worked on an embedded system this summer written in straight C. It was an existing project that the company I work for had taken over. I have become quite accustomed to writing unit tests in Java ...
851 votes
14 answers
723k views

How do I properly assert that an exception gets raised in pytest?

Code: # coding=utf-8 import pytest def whatever(): return 9/0 def test_whatever(): try: whatever() except ZeroDivisionError as exc: pytest.fail(exc, pytrace=True) Output:...
Gill Bates's user avatar
  • 15.1k
809 votes
17 answers
357k views

What are the differences between unit tests, integration tests, smoke tests, and regression tests? [closed]

What are unit tests, integration tests, smoke tests, and regression tests? What are the differences between them and which tools can I use for each of them? For example, I use JUnit and NUnit for ...
caltuntas's user avatar
  • 10.8k
675 votes
12 answers
571k views

How to run only one unit test class using Gradle?

I am new to Gradle. I use Gradle 1.10 and Ubuntu 13. I want to know if there's any command to execute only one unit test class, similar to testOnly in SBT.
bula's user avatar
  • 9,099
559 votes
7 answers
266k views

Writing unit tests in Python: How do I start? [closed]

I completed my first proper project in Python and now my task is to write tests for it. Since this is the first time I did a project, this is the first time I would be writing tests for it. The ...
user225312's user avatar
  • 130k
524 votes
14 answers
213k views

How to unit test abstract classes: extend with stubs?

I was wondering how to unit test abstract classes, and classes that extend abstract classes. Should I test the abstract class by extending it, stubbing out the abstract methods, and then test all the ...
Paul Whelan's user avatar
  • 16.7k
486 votes
18 answers
434k views

How do I run all Python unit tests in a directory?

I have a directory that contains my Python unit tests. Each unit test module is of the form test_*.py. I am attempting to make a file called all_test.py that will, you guessed it, run all files in the ...
Stephen Cagle's user avatar
470 votes
15 answers
244k views

What is the difference between unit tests and functional tests?

What is the difference between unit tests and functional tests? Can a unit test also test a function?
mousey's user avatar
  • 11.8k
414 votes
31 answers
162k views

Should I test private methods or only public ones? [closed]

I have read this post about how to test private methods. I usually do not test them, because I always thought it's faster to test only public methods that will be called from outside the object. Do ...
Patrick Desjardins's user avatar
314 votes
7 answers
163k views

New to unit testing, how to write great tests? [closed]

I'm fairly new to the unit testing world, and I just decided to add test coverage for my existing app this week. This is a huge task, mostly because of the number of classes to test but also because ...
pixelastic's user avatar
  • 5,198
223 votes
21 answers
334k views

How to test code dependent on environment variables using JUnit?

I have a piece of Java code which uses an environment variable and the behaviour of the code depends on the value of this variable. I would like to test this code with different values of the ...
vitaut's user avatar
  • 53.6k
221 votes
16 answers
286k views

How to measure test coverage in Go

Has anyone succeeded in generating code coverage for Go unit tests? I can't find a tool for that on the web.
Georgi Atsev's user avatar
  • 2,985
201 votes
31 answers
88k views

Disadvantages of Test Driven Development? [closed]

What do I lose by adopting test driven design? List only negatives; do not list benefits written in a negative form.
196 votes
16 answers
87k views

Python unit test with base and sub class

I currently have a few unit tests which share a common set of tests. Here's an example: import unittest class BaseTest(unittest.TestCase): def testCommon(self): print 'Calling BaseTest:...
Thierry Lam's user avatar
162 votes
6 answers
101k views

What is a "Stub"?

So, carrying on with my new years resolution to get more in to TDD, I am now starting to work more with Rhino Mocks. One thing I am keen to do is to make sure I really grok what I am getting into, so ...
Rob Cooper's user avatar
  • 28.8k

15 30 50 per page
1
2 3 4 5
443