unit-testing

Unit Testing and Web Apps - Resources

In a J2EE web application, how do people manage resources so that they are visible to both the web context and to unit/integration tests? I find that often you end up having your source/resource folders configured a certain way during development (i.e., what Maven expects) and so your unit tests will run in your IDE. But once the web ap...

How to unit-test a file writing method with Visual Studio's built-in automated tests?

I use Visual Studio 2008 Professional automated tests. I have a function that writes to a file. I want to unit test the file writing function. I have read somewhere that I would have to mock a file somehow. I don't know how to do it. Can you help? How to unit-test a method that downloads a page from the Internet? ...

How to open a file inside a Test Project code folder? (Visual Studio 2008 and .NET C#)

When I run a Test Project on Visual Studio I use the code below to access a file inside the test project code folder var Location = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName ); var FileLocation = Path.Combine( Location ,@"..\..\..\TestProject1\App_Data\da...

Suggest a JPA Unit test framwork

How to unit test JPA code? is there any way to generate Unit Test case itself? Note : I am lazy and new to Unit Test code. ...

Are the unit test case for JPA worthy? anyway it is just going to access DB, why do we need it?

Are the unit test case for JPA worthy? anyway it is just going to access DB, why do we need it? ...

Proper unit testing: testing a method with no [accessible] state or return value

Hi all, I'm somewhat new to unit testing. One thing (for now) about proper testing confuses me. For instance, how do you test a main method if it has no state and only console output? Like this, where myServer methods & state are private? public static void main(String[] args) { Server myServer = new Server() if(myServer...

Basic unit test and C, how do I get started?

Hi After reading quite some threads here at StackOverflow, I have come to the conclusion that I should adopt to some form of test driven development/unit test (or at least explore the area). And since we are talking about c code under Linux, I decided to give check a try (I don't know if this is the right choice but if it's no goo...

How do code coverage tools work in different languages?

Most established languages have solid test coverage tools available for them, but the depth of functionality differs significantly from one to another. Also, all the various VMs and compilers have such heterogeneous structure that writing a code coverage tool must be a very different job in C than in Lisp, for example. Python has sys....

Having issues with moq

I am trying out moq and I'm running into a problem with the following test body: var child = new Mock<ZooNode>(); var parent = new Mock<ZooNode>(); child.Object.Parent = parent.Object; parent.Expect(p => p.Children.Contains(child.Object)).Returns(true); which throws : System.ArgumentException: Invalid expectation on a non-overr...

unit testing, refactoring, IO

You have a method on a class that has 2 parameters, one of which is a file path, the other is irrelevant. InterestingResult result = foo.Bar(irrelevant, filePathInfo); In the spirit of having fast snappy unit tests, you find yourself considering refactoring this method to pull out the file path to remove the IO requirements of this te...

Should we use FxCop on UnitTest assemblies?

We use FxCop for all of our projects. For our UnitTests I am not sure it is worth it. We end up with many suppresses: [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = SuppressJustifications.CA1822MethodIsUsedExternallyAsNonStatic)] [SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResu...

Is it overkill to run the unit test with Valgrind?

Hi Just some days ago I started looking into a unit test framework called check, and I intend to run the test on c code under Linux. Now check and some well designed code and some test code can help me to verify that the basic functionality is correct, I mean it is quite easy to just look at the variables in and response back and ...

Unit-testing data binding in System.Windows.Forms

I'm facing a problem while unit testing my forms. The problem is that data bindings are simply not working when the form is not visible. Here's some example code: Data = new Data(); EdtText.DataBindings.Add( new Binding("Text", Data, "Text", false, DataSourceUpdateMode.OnPropertyChanged)); and later on: Form2 f = new Form2(); ...

C# UnitTest - Assert.AreEqual() does not call Equals if the argument is null

Hello, i recently stumbled upon a seemingly weird behavior that Google completely failed to explain. using Microsoft.VisualStudio.TestTools.UnitTesting; class TestClass { public override bool Equals(object obj) { return true; } } [TestMethod] public void TestMethod1() { TestClass t = new TestClass (); Assert...

Unit test and Web test on the .NET Framework?

I would like to know what a Unit test and Web Test is in the .NET Framework and What are the difference between these tests? and How does it affect with the implementation of the CSLA.NET? Please help, thanks! ...

Continuous Integration: keeping the test DB schema up-to-date

Hi, I'm setting up a continuous integration server (Hudson) to build a Java project and run the relevant unit/integration tests. Most of these tests access a database and the test data is kept in a DbUnit XML file. I'm looking for a way to automatically keep the test database schema up-to-date. Currently the SQL script for a particular...

How to handle large strings in unit tests?

Hi! I've got a question about testing methods working on strings. Everytime, I write a new test on a method that has a string as a parameter. Now, some issues come up: How to include a test string with \n, \r, \t, umlauts etc? How to set the encoding? Should I use external files that are opened by a FileInputStream? (too much overhea...

What steps would you recommend to move from TDD to BDD?

If you want to move your development process from Test-Driven Development to Behavior-Driven Development what path would you take or recommend? What are the possible challenges that you might face? Moving the development process will be a huge task itself as the paradigm changes, a shift happens in the thought process and the outlook o...

Unit testing...should it be used here?

Duplicate: http://stackoverflow.com/questions/135651/learning-unit-testing I'm trying to develop some software for my research group to analyze and plot experimental data. I would like to make it were it's pretty error free. Would this be a situation for unit testing? If so could you possibly point me to some good references for un...

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 in to, so I wanted to check my understanding of what I have seen so far (and I thought it would be good to get it up here as a resource). What is ...