unit-testing

Testing your code programmatically: by the programmer or someone else?

So here is the situation-- a quote from my boss: "[...] we need to focus on programming. [...] At the end of the day I want to write good software and not get bogged down with testing." This is said after we have had 3 months of a daunting list of bugs and recently designating a non-programmer to write web tests with Selenium framework...

tests for data access (sql queries) functionality

hello guys, I want to know the best way of testing data access functionality. I know that it is possible to create mocks to change data layer objects that is using to test business logic. However is it possible to test if sql queries to database are correct. Scenario: A method must return employees which were applied for work last mont...

Unit-testing with dependencies between tests

How do you do unit testing when you have some general unit tests more sophisticated tests checking edge cases, depending on the general ones To give an example, imagine testing a CSV-reader (I just made up a notation for demonstration), def test_readCsv(): ... @dependsOn(test_readCsv) def test_readCsv_duplicateColumnName(): ... @d...

How can I write tests in one Eclipse project for classes from another Eclipse project?

I want to be able to have two projects, one that contains production code and one that contains test code. This shouldn't necessarily be an Android-specific question, but I'm want to write some unit tests for some non-platform-specific Android code on the host PC. I created a new Java project so I can run the unit tests on the PC a...

Groovy MockFor - how to handle calls to "with" methods on mocks

I faced with interesting problem while using mocking support in Groovy to test collaboration with dependency. We have two classes (example): class Dependency { void method() { throw new OperationNotSupportedException() } } class Dependent { Dependency dependency void useDependency() { dependency.with ...

When to use debug vs unit tests?

I'am a little bit confused what is better to use debug or write unit test? and is this general or there are cases where debug better than unit test?or should I use both of them? Thanks ...

Testing custom ModelBinder against HTTP context in ASP.NET MVC (1.0)

Hi, I'm trying to unit test a custom model binder - specifically, I want to see how it responds to various (possibly conflicting) values being submitted in the Request.Form and Request.QueryString collections - i.e. if I submit one value in the form and another in the querystring (yeah, yeah, I know, this is evil, but I want test covera...

Unit-Test, Integration test or problem in design?

Hi, I'm written my first unit-test and I think it is too dependent on other modules and I'm not sure whether it's because: It's a complex test I've actually written an integration test or I have a problem in my design I'll first say that although I have around 4 years of experience in development I never learned, nor were taugh...

Unit testing/documentation/code implementation in the same file?

Today we have documentation and code implementation in the same file: # @returns <String> A combined string def say :this :that return "#{this} "{that}" end I have never seen unit testing in the same file like: # @if_insert "good", "morning" # @should_return "good morning" # # @returns <String> A combined string def say :this :tha...

Is there an alternative to CHESS for testing programs written with Task Parallel Library

I am looking for a tool that will allow me to execute unit tests over all possible interleavings (spelling?) with a program that was written with Task Parallel Library constructs. Alternatively, how could I run CHESS with dotNET 4.0? ...

Success unit testing pyinotify?

I'm using pyinotify to mirror files from a source directory to a destination directory. My code seems to be working when I execute it manually, but I'm having trouble getting accurate unit test results. I think the problem boils down to this: I have to use ThreadedNotifier in my tests, otherwise they will just hang, waiting for manual...

basic ruby testing question

I've found myself doing this a lot lately... how can I improve the declaration of the paperclip fixture? (sorry, noob question I know) class ProjectTest < ActiveSupport::TestCase def xxx project = Project.new({ :name => 'xxx', :attachment => File.new(Rails.root + 'test/fixtures/files/attachments/xxx.psd') }) p...

How do I unit test and mock a static extension method with Rhino Mocks?

Hello, I have following extension method written: static public IQueryable<OutboundPattern> ByClientID(this IQueryable<OutboundPattern> qry, int clientID) { return from p in qry where p.ClientID == clientID select p; } I also have the following service layer method written: public I...

How to construct unit test

I have custom event logger, and I want to test it. [Test] public void AddLogWithExceptionAndEventLogEntryTypeTest() { const string loggerName = "mockLoggerName"; var logger = new MyLogger(loggerName); System.Diagnostics.EventLog log = new System.Diagnostics.EventLog("System"); string log...

stubbing factory_girl + rspec methods and attributes

I'm using factory_girl + rspec on Rails 2-3-stable: Test: context "test" do before(:each) do @profile.stub!(:lastfm_enabled?).and_return(true) end it "should be able to scrobble if true" do @profile.update_attribute(:lastfm_scrobbling, true) @profile.lastfm_scrobbling_enabled?.should be_true...

C# - WPF : testing strategies

I'm new to C#4 and WPF and I'm about to start a new application. Coming from a C++/MFC world, I'm interested in testing strategies used with up to date technologies. From instance : Unit Testing Functionnal testing UI Testing other? Any advices would be appreciated. Thanks ...

In javascript, how can you assert that two items are equal?

I am running Rhino and trying to determine how to do an assert_equals() or its equivalent in Javascript. From the Rhino shell I can load qunit, but I can't create an assertion that will fail. What is the easiest way to use assertions in Javascript? I will be using Javascript in environments other than a web browser, so knowing how to d...

How to copy to unit test out-folder?

I have created a test project to test my WPF project. One of my methods needs to read from a file, which is copied into the bin folder C:\..\ProjectName\Bin\Debug\ when compiling. The method works fine, but when running the unitTest it searches for the file in C:\..\ProjectName\TestResult\UserName_computerName-Date\Out\ How can I ...

How to make VS Unit Test show the Error Message from exceptions other than UnitTestAssertException?

I'm using VS Unit Testing Framework and Moq. When a Moq verification fails, I'll get a Moq.MockException. In the Test Results window, instead of showing the helpful message inside the exception, it just says "Test method XXX threw exception: ..." Is there a way to tell the VS Unit Test framework always display the message of exceptions...

Linker Error in Objective-C static library with unit testing

In my Cocoa Touch static library project, I have a target set apart for unit testing with OCUnit. When I build the project, I have several unit tests that are supposed to automatically run, but when I actually build the project, I get this linker errors: "_OBJC_CLASS_$_ObjectIntTreeMap_ObjectEntry", referenced from: objc-class-ref-to-Ob...