Archive for September 2009

Want to use a Mock?

You are wrong! Well in most cases. It seems above the intellectual means of most agile developers (the non-agile developers don’t write tests) to realize that tests like the following are useless and even harmful. It is not giving me anything apart from test sclerosis.

  [Test]
        public void ShouldGetAllByauthorId()
        {
            //given
            var mockRepository = MockRepository.GenerateMock<IContentRepository>();
            var authorRepository = MockRepository.GenerateMock<IAuthorRepository>();
            var subcategoryRepository = MockRepository.GenerateMock<ISubCategoryRepository>();
            var contentService = new ContentService(mockRepository, authorRepository, subcategoryRepository);
 
            //when
            contentService.GetContentByAuthorId(1);
 
            //then
            mockRepository.AssertWasCalled(repository => repository.GetContentByAuthorId(1));
        }

A healthy six lines of code to test this:

   public IList<Voucher> GetContentByAuthorId(long authorId)
        {
            return contentRepository.GetContentByAuthorId(authorId);
        }

Verdict: Waste in an agile disguise.

Selenium

A warning to myself, as I forgot over the last year and might forget again.

  • Selenium is bloody slow.
  • Selenium produces crappy error messages.
  • Selenium sports a highly unintuitive vaguely documented api (at least it always takes ages to find the right docs on
    the web).
  • Selenium is unreliable.

Use WebDriver!