unit-testing

Unit testing functions that access files

i have two functions one that builds path to set of files and another that reads the files the function as below def pass_file_name(self): self.log_files= [] file_name = self.path+"\\access_"+self.appliacation+".log" if os.path.isfile(file_name): self.log_files.append(file_name) for i in xrange(7): fil...

Clean Way to Test ASP.NET MVC Controller Without Hitting Database?

I'm trying to think of a good way to clean up my controllers to make them more testable without having to rely on a constant database connection. I thought I had a decent start by abstracting away my object context with an IObjectContext. This works well for the context, but my next problem is that I have a generic repository that I use ...

Is there a .net thread shaker for I can use from unit tests?

I am writing a unit test for some thread locking logic, so as to make the test more likely to fail quickly; I wish to have all the threads switch between each other very often and at random times. I know this will not prove we don’t have any bugs, but at least it should make the bugs show up more often. Thanks to everyone saying "don...

JSF Unit test getStyleClass requires FacesContext

I would like to add a unit test to test the style class gets set correctly. Unfortunately the getter getStyleClass requires a FacesContext. Any ideas? ...

Help create a unit test for test response header, specifically Cache-Control, in determining if caching has been disable or not...

Scenario: I have a base controller which disables caching within the OnActionExecuting override. protected override void OnActionExecuting(ActionExecutingContext filterContext) { filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1)); filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false)...

Unit Testing - Lame Error Message - "Failed to queue test run" "Invalid syntax"

I am trying to run my units test and it is failing. Not much info is supplied by Visual Studio. When I click on the "Test Run Error" link I get this screen. This is spectacularly unhelpful. Does anyone know where I can get a call stack on what is really happening? The solution builds just fine so I don't see how it can be "Invalid...

Is there an automated way to merge C++ implementation(.cpp) and header (.h) files

Hi, I am trying to create a unit test framework using CPPUnit for a large code base. I need to be able to test individual modules, all of which are part of a module tree that begins with a specific root module. Due to a non-technical reason, I cannot touch the production file (my original approach involved adding an ifdef to the root m...

How to test logic which is dependent on current date

I have this method which is dependent on current date. It checks if today is Sun, Mon, Tue or Wed, then it gives 5 days of lead time for arrival of shipped items. If its Thur, Fri or Sat then it gives 6 days of lead time to account for the weekend. private DateTime GetEstimatedArrivalDate() { DateTime estimatedDate; if (DateTi...

How can I split abstract testcases in JUnit?

I have an abstract testcase "AbstractATest" for an interface "A". It has several test methods (@Test) and one abstract method: protected abstract A unit(); which provides the unit under testing. No i have multiple implementations of "A", e.g. "DefaultA", "ConcurrentA", etc. My problem: The testcase is huge (~1500 loc) and it's growin...

Seam unit testing with exception filter and expectedExceptions annotation

I've got a unit test for a Seam component that should fail if a value isn't provided in the context before the backing bean is created. I've been able to test this manually but would like to cover this scenario with a unit test. I'm basically getting a org.jboss.seam.InstantiationException caused by a java.lang.IllegalArgumentException ...

Does Maven surefire plugin run tests using multiple threads?

I'm wondering if the Maven surefire plugin either runs tests multi-threaded by default (and if so can the number of threads be controlled? ) or if it runs tests from the Test classes in a random order or predictable order, or if the order can dictated by some means. I haven't verified this yet (I'll do so tomorrow just looking for som...

Organizing unit test within a test class

Suppose I have several unit tests in a test class ([TestClass] in VSUnit in my case). I'm trying to test just one thing in each test (doesn't mean just one Assert though). Imagine there's one test (e.g. Test_MethodA() ) that tests a method used in other tests as well. I do not want to put an assert on this method in other tests that use ...

How to run nosetests from netbeans?

I recently started using netbeans for python development and really like it. However, the test runner in netbeans does not run my doctests, nor does it run my test functions written using nose. I always have to switch to the shell and run 'setup.py test' or 'nosetests' manually. Is there a way to integrate this into netbenas 6.8? ...

Does NUnit provide a way to assert that events of objects get subscribed to?

I have an object that gets passed into a method as a parameter. This object has a event on it which should get subscribed to when I call this method with the object as the argument. Does NUnit allow me to check this? Edit: Added a code sample: [Test] public void AddingToCollectionShouldHookPropertyChangedEventUp() { ...

Ability to pass array to mocked method call

Hi all, I have a method that i want to mock that takes an array as a argument. In a real call, the method would modify this array and the resultant array would be use further along in code. What i tried to do was pass in array to the mocked method call, that had values that would be valid when the array is used again. However what i fin...

Unable to automatically debug "xxxx". Attaching to the server process failed. Mixed mode debugging is not supported on Windows 64-bit platforms.

We are getting the above error when we try and run our tests in debug mode. We have a .net solution written in C#, which we have developed using Visual Studio 2008 on Windows XP. We have now got new machines :). Windows 7 64 bit. The solution has several wcf host and web services host, it also runs some windows workflows. It appears ...

xVal Causing NUnit to Crash when checking ModelState.IsValid

I am trying to run a simple test on a controller in MVC. This controller validates the input using xVal and DataAnnotations. When I run the test (using NUnit via Resharper, NUnit standalone or TestDriven.Net) it crashes the runner with no decent error message. In the event logs it just has a fairly generic .NET Runtime 2.0 Error Repor...

In MVVM with WPF how to I unit test the link between the ViewModel and the View

In MVVM it is normal to connect View to the ViewModel with data binding. Therefore if the name of a properties changes on one of the Model objects that is databound to there is no compiler error. When the compiler will not stop a bug, the next thing I think of is “UnitTest”, However How do you unit test this without spending for...

Test results and code coverage status on LCD Screen

HI, We are a small TDD team. We have a LCD screen mounted on the wall which we would like to have display the status of our builds together with current code coverage. Are there any tools that will provide this out ot the box? If not is this pretty straight forward to develop on our own? We are using TFS 2008. Cheers! ...

What class should I inherit to create a database integration test in case of Spring?

I want to create a unit test for integration testing. What class should I inherit to be able to commit/rollback transactions? AbstractTransactionalSpringContextTests is deprecated. It's recommended to use AbstractJUnit38SpringContextTests instead, but I cannot find how to control transactions there. ...