Do MSTest deployment items only work when present in the project test settings file?

This post here helped me figure out what I needed to do WITHOUT having to manually add items to the .testsettings file. Step 1 – Enable the MS Test DeploymentItem attribute. First up, we need to turn on / enable the DeploymentItem attribute. Go to TEST -> EDIT TEST SETTINGS -> Current Active settings .. … Read more

How to test my servlet using JUnit

You can do this using Mockito to have the mock return the correct params, verify they were indeed called (optionally specify number of times), write the ‘result’ and verify it’s correct. import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.io.*; import javax.servlet.http.*; import org.apache.commons.io.FileUtils; import org.junit.Test; public class TestMyServlet extends Mockito{ @Test public void testServlet() throws … Read more

Is UnitOfWork and GenericRepository Pattern redundant In EF 4.1 code first?

This is duplicate of many topics already discussed on SO but I agree that some of them can be hard to find because they are nested in other question What’s the point of Generic repository in EF 4.1 Challenges with testable and mockable code in EF Another question about challenges with mocking EF code Implementing … Read more

Mocking $modal in AngularJS unit tests

When you spy on the $modal.open function in the beforeEach, spyOn($modal, ‘open’).andReturn(fakeModal); or spyOn($modal, ‘open’).and.returnValue(fakeModal); //For Jasmine 2.0+ you need to return a mock of what $modal.open normally returns, not a mock of $modal, which doesn’t include an open function as you laid out in your fakeModal mock. The fake modal must have a result … Read more

Random data in Unit Tests?

There’s a compromise. Your coworker is actually onto something, but I think he’s doing it wrong. I’m not sure that totally random testing is very useful, but it’s certainly not invalid. A program (or unit) specification is a hypothesis that there exists some program that meets it. The program itself is then evidence of that … Read more