Top "Unit-testing" questions

Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.

How do I test a private function or a class that has private methods, fields or inner classes?

How do I unit test (using xUnit) a class that has internal private methods, fields or nested classes? Or a …

java unit-testing tdd
How to mock void methods with Mockito

How to mock methods with void return type? I implemented an observer pattern but I can't mock it with Mockito …

java unit-testing mocking mockito void
Mocking static methods with Mockito

I've written a factory to produce java.sql.Connection objects: public class MySQLDatabaseConnectionFactory implements DatabaseConnectionFactory { @Override public Connection getConnection() { try { …

java unit-testing static mocking mockito
How do I generate a stream from a string?

I need to write a unit test for a method that takes a stream which comes from a text file. …

c# unit-testing string stream
Mockito : how to verify method was called on an object created within a method?

I am new to Mockito. Given the class below, how can I use Mockito to verify that someMethod was invoked …

java unit-testing junit mockito
How do I use Assert to verify that an exception has been thrown?

How do I use Assert (or other Test class?) to verify that an exception has been thrown?

c# unit-testing mstest assert vs-unit-testing-framework
JavaScript unit test tools for TDD

I've looked into and considered many JavaScript unit tests and testing tools, but have been unable to find a suitable …

javascript unit-testing tdd
How do you test that a Python function throws an exception?

How does one write a unittest that fails only if a function doesn't throw an expected exception?

python unit-testing exception exception-handling
Unit Testing C Code

I worked on an embedded system this summer written in straight C. It was an existing project that the company …

c unit-testing testing embedded
How to run test methods in specific order in JUnit4?

I want to execute test methods which are annotated by @Test in specific order. For example: public class MyTest { @Test …

java unit-testing junit junit4