unit-testing

How to list all methods-of-a-class/classes that are not tested?

I want to have a list of not-tested methods/classes but not sure how to get it. Please help. [Edit] I'm using test framework Moq. ...

Best practices for database testing with PHPUnit

PHPUnit's own manual has some as-yet-unwritten sections entitled "Operations" and "Database Testing Best Practices." What are best practices for testing a database with PHPUnit, particularly in MySQL? ...

Perl: avoid greedy reading from stdin?

Consider the following perl script (read.pl): my $line = <STDIN>; print "Perl read: $line"; print "And here's what cat gets: ", `cat -`; If this script is executed from the command line, it will get the first line of input, while cat gets everything else until the end of input (^D is pressed). However, things are different when the i...

Do we need to unit test the GUI when using proper abstraction?

With a good design pattern like MVP, MVC, etc we aim to move all logic out of the GUI. That leaves us with a light weight GUI which ideally just need to "bind" its buttons and fields to properties in some business logic layer. This is a great approach as this layer will be free from GUI stuff, and we can easily write unit tests for it. ...

MSTest can not find App_GlobalResources assembly

Trying to unit test a web application using mstest I have that problem with resources included in App_GlobalResources folder in the web applications. Those resources are built at runtime and because of that they are not found when running the unit tests. How are you solving this problem? ...

Resharper 4.x and csUnit

Hi, I am looking for a way to integrate test framework csUnit and ReSharper 4.x. I need prepared plugin (better with sources) or sample how to implement such plugin. Thank you, Igor. ...

Code Coverage on Lambda Expressions

I'm seeing a pattern throughout my code where the lambda expression is showing as not covered in code coverage, the debugger DOES step through the code and there are no conditional blocks. public CollectionModel() { List<Language> languages = LanguageService.GetLanguages(); this.LanguageListItems = languages.Select( ...

How can I unit test code that sends a SOAP web-service request?

I want to write a unit test for some code that generates a SOAP message with an attachment and sends it: SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance(); conn = factory.createConnection(); conn.call(message, endpoint); where the factory is a javax.xml.soap.SOAPConnectionFactory I don't care about any response co...

Why F5 does not start a unit test in VS2008?

Hello, I have a solution with several projects and all of them are unit test projects. While I can start some tests selecting the project as the startup project and pressing F5 there are other projects that when selected as startup and pressed F5 says that a project with an ouput type of class library can not started. I've compared the...

C# - Unit test, Mock?

The builtin unit test generator(VS) for the target classes should that be used or should I learn myself how to write a unit test? And whats this "Mock" thing? I hear it over and over but none cares to give a god damn explanation.. Thanks in advance. ...

How to write unit test for "InterruptedException"

In attempts of 100% code coverage, I came across a situation where I need to unit test block of code that catches an InterruptedException. How does one correctly unit test for this? (JUnit 4 syntax please ) private final LinkedBlockingQueue<ExampleMessage> m_Queue; public void addMessage(ExampleMessage hm) { if( hm!=null){ try ...

When and when not to stub/mock a test

I am making a concerted effort to wrap my head around Rspec in order to move towards more of a TDD/BDD development pattern. However, I'm a long way off and struggling with some of the fundamentals: Like, when exactly should I be using mocks/stubs and when shouldn't I? Take for example this scenario: I have a Site model that has_many :b...

How to test asp.net email is being sent

Hi, I have some code in my asp.net which sends an email: public void SendEmail(string message) { var body = message; var email = new MailMessage(ConfigurationManager.AppSettings["SenderEmail"], ConfigurationManager.AppSettings["RecipientEmail"], "Email Test", body); v...

Why is a menu item disabled when using SWTBot?

I've written up a GUI test using SWTBot to test the Extract Method refactoring. I use editor.selectRange() to select a statement to extract into a method. But, when I run the unit test, the Extract Method refactoring menu item is disabled. Thus, SWTBot fails to invoke the refactoring. The whole project containing the above unit test is ...

MbUnit's row attribute in NUnit?

While reading an Asp.Net MVC code sample that used MbUnit as it's testing framework, I saw that it was possible to run a single test against multiple input possibilities by using a Row attribute, like so: [Test] [Row("test@test_test.com")] [Row("sdfdf dsfsdf")] [Row("[email protected]")] public void Invalid_Emails_Should_Return_False(string in...

How to test software behaviors that occur at certain interval of time?

I am working on a ad-related project, in which I need to make sure that our system picks up an advertisement from db at certain interval of time and insert it into our normal service flow. How would you design test for systems like this so that you don't have to wait 30 mins while confirming that advertisement do occurs at the right tim...

Is Assert-ing on tearDown (@After) method wrong?

I have multiple test cases even and if the logic is different, the output must be equal on all of them. So I was thinking in how to generalize them and place the Assert method only once. Is there any way better to do it than this one: static public class Tests() { private static String expected = null; private String actual = ...

Suggestions for unit testing

Hello another question concerning debugging : Automatically generating test cases when i know the parameterset. And doing it all at once, instead during development (could kick myself) i have a set of parameters for my software that i wish to test. (~ 12 parameters only). However of course these parameters are often integers, so for eve...

Test that void method didn't get called with EasyMock

Is this possible? I tried with EasyMock.expectLastCall().times(0); but EasyMock complains that times must be >=1 ...

Pack Urls and Unit Testing. Problem with my environment?

...