unit-testing

Spring Integration Test is Slow with Autowiring

I am trying to speed up the Integration tests in our environment. All our classes are autowired. In our applicationContext.xml file we have defined the following: <context:annotation-config/> <context:component-scan base-package="com.mycompany.framework"/> <context:component-scan base-package="com.mycompany.service"/> ...additional di...

How to catch an assert with google test?

Hello, I'm programming some unit test with google test framework. But I want to check is some asserts are well placed and are useful. So my question is: does exists a way to catch an assert in google test? Example: int factorial(int n){ assert(n >= 0); //.... } And then the test: #include <gtest/gtest.h> TEST(FactorialTest,...

How much additional time does unit testing take?

I am looking for possibly a study between the time difference of regular coding vs coding + unit tests (not strict TDD just yet). I know the whole "Saves you time in the long run" angle, but from a project planning perspective for the team that has never done it before, I need to be able to roughly estimate how much additional time to al...

[WPF] How can I force a textBox in wpf to call OnLostFocus in a unit test?

I have a custom component created in WPF using C#, where I have some validation that are checked when the textbox OnLostFocus is called (it is only when the user leaves the textbox I can do the validation, since only then do I have the complete input string to validate). How can I trigger the OnLostFocus on the textBox from the unit tes...

Skip unit tests that take a long time

Hi, I'm working with MS-Test for my unit tests writing. most of my tests have a duration of less than 0.1 seconds. I want to somehow tell VS "ignore the tests that take a long time to run when i'm running the tests manually, and when you run them on the build do not ignore them. I know that in nunit there is an "explicit" attribute tha...

Is there a good in-memory database that would act like DB2

I am currently using DB2 to do unit tests, but it is sometime quite slow. I would need a good in-memory database that would include all the feature of DB2. Does this type of in-memory database exist, or do they only allow standard SQL feature? Thank you. EDIT The DB2 Database is on a remote server, so I would need a solution to replica...

Is there a .NET Testing framework that can assert a collection contains elements based on an expression?

I'm trying to test that a certain function I'm building will add objects to a collection when supplied with a collection of Ids. My test looks something like this: var someClass = new SomeClass(); var someIds = new List<Guid> { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() }; someClass.AddIds(someIds); Asset.That(someClass.IdsInClas...

Objective-C Testing Frameworks

Are there any tools or plugins for XCode that can generate test cases for your apps? ...

How do I give file path for code to be checked in at TFS?

I am writing a test code (I'm just a beginner) where I need to give a file name located in my local box. I need to check-in this code as well as the file in TFS, so that when other people take latest version, they get both. //At my local box string myFilePath= "D:\BACKUP\samplefile.extension"; For TFS check-in, I gave following path ...

Where to put common Unit Test code in ruby on rails environment?

Using Rails 3.0, I have a small bit of code that I seem to be calling in all my Unit tests. Is there a common place to put shared unit test code that won't be incorporated into both unit and functional tests? I'd rather ONLY incorporate it into the needed files, just the unit tests. I'm new to testing practices in general. Is it common...

How to use "Pex and Moles" library with Entity Framework?

This is a tough one because not too many people use Pex & Moles or so I think (even though Pex is a really great product - much better than any other unit testing tool) I have a Data project that has a very simple model with just one entity (DBItem). I've also written a DBRepository within this project, that manipulates this EF model. R...

Mock object creation inside a method

If I have the following method: public void handleUser(String user) { User user = new User("Bob"); Phone phone = userDao.getPhone(user); //something else } When I'm testing this with mocks using EasyMock, is there anyway I could test the User parameter I passing into my UserDao mock like this: User user = new User("Bob")...

Howto overcome Unit Test Regression Problems...?

Hi, I was looking for some kind of a solution for software development teams which spend too much time handling unit test regression problems (about 30% of the time in my case!!!), i.e., dealing with unit tests which fails on a day to day basis. Following is one solution I'm familiar with, which analyzes which of the latest code change...

I am new to automated testing in Java. Which tool should I prefer? JUnit or TestNG?

I have read some comparisons of JUnit and TestNG and it looks like TestNG has more configuration options. On the other hand JUnit is more supported by IDEs, building tools, has more plugins. I have no experience in writing unit tests. Which tool should I prefer? P.S. I think my question is more like: Should I give TestNG a try, or just...

scheduling Jmeter distributed testing

I am using JMeter's distributed testing feature which works fine. However, when I schedule this distributed run, it just runs immediately and disregards schedules. It happens only for distributed testing. Any idea? ...

is it possible to make test method parameterized, not an entire class?

As I understand, with JUnit 4.x and its annotation org.junit.runners.Parameterized I can make my unit test "parameterized", meaning that for every set of params provided the entire unit test will be executed again, from scratch. This approach limits me, since I can't create a "parameterized method", for example: .. @Test public void t...

Run Rails Tests without Dropping Test Database

Hi there, Just wondering if there's a way to run Rails tests without dropping the database. I'm currently only executing unit tests and am using the following rake command to do so: rake test:units. Thanks for the help in advance! Just in case this is relevant: Rails 3 Ruby 1.8.7 (MRI) Oracle 11g Database activerecord-oracle_enhan...

Mixing Assert and Act in AAA unit testing syntax

Is it OK to mix Assert and Act steps? Is AAA more of a guideline than a rule? Or am I missing something? Here is my test: [TestMethod] public void CancelButtonSelected_DontCancelTwiceThenCancel_DialogCloses() { // Arrange IAddAddressForm form = Substitute.For<IAddAddressForm>(); // Indicate that when Show CancelMessage is...

Python unittest - invoke unittest.main() with a custom TestSuite

I'm making unittests with python. I am not using any automatical test discovery. I am assembling TestCases into a TestSuite manually. I can run these tests with unittest.TextTestRunner().run(suite), I would like to run them with unittest.main() so that I can use command line options (like -v/--failfast). The documentation says that unit...

How to do database unit testing?

I have heard that when developing application which uses a database you should do database unit testing. What are the best practices in database unit testing? What are the primary concerns when doing db unit testing and how to do it "right"? ...