3 Replies - 395 Views - Last Post: 11 April 2018 - 10:39 AM Rate Topic: -----

#1 aidenkael   User is offline

  • D.I.C Regular
  • member icon

Reputation: 65
  • View blog
  • Posts: 299
  • Joined: 22-October 13

Assert.Pass("Nothing to test yet")

Posted 05 March 2018 - 02:33 PM

Just found this at my new job:

_redisCacheMock.SetStringAsync("", "", null).ReturnsForAnyArgs(Task.CompletedTask);

await _redisRepo.Set(sample);

Assert.Pass("Nothing to test yet");


Is This A Good Question/Topic? 0
  • +

Replies To: Assert.Pass("Nothing to test yet")

#2 ndc85430   User is online

  • I think you'll find it's "Dr"
  • member icon

Reputation: 833
  • View blog
  • Posts: 3,355
  • Joined: 13-June 14

Re: Assert.Pass("Nothing to test yet")

Posted 05 March 2018 - 10:27 PM

That's disappointing :(/>. We test drive our software, so I naturally expect working unit tests to be committed with the implementation.

Also, as an aside, why do you think integration tests are pointless?

This post has been edited by ndc85430: 05 March 2018 - 10:31 PM

Was This Post Helpful? 0
  • +
  • -

#3 aidenkael   User is offline

  • D.I.C Regular
  • member icon

Reputation: 65
  • View blog
  • Posts: 299
  • Joined: 22-October 13

Re: Assert.Pass("Nothing to test yet")

Posted 06 March 2018 - 08:40 AM

Not pointless entirely, but pointless in the way they are used in much of the industry. A small example:

Software A passes a string to Software B, and Software B returns a json object.

IMO, this should be tested (happy path only for this example), with unit tests: Deserialize json object as class (software A), and Given string input, returns json object (software B)/>.

If both these pass, I can safely say for a fact that if I give Software B a string, it will give me a json object. I don't need to do an integration test for this, because I have already proved it works. I just need to make sure there is proper handling of things like network interruption, dropped packets resulting in bad json, one of the services is down, etc. Sample code for the first unit test:
public static async Task SoftwareA_DeserializeJsonIntoClass_ValidJson()
{
     //Arrange
     string output = "something";
     var json = await _mockedSoftwareB.GetAsync(output); //We mock software B's call here, so that it is a unit test
    //Act
    var result = JsonConvert.Deserialize<MyClass>(json);
    //Assert
    result.IsOfType<MyClass>();
}



If I do an integration test now, what am I really testing? My network, and other things outside of my control. This, to me, is wasted code and time. Network problems should be handled by my code, i.e., I should also have tests around what happens if software B returns a 404, 400, 500, etc., what if it is null, what if it returns 200 but is bad json, etc.

P.s. the above code was written from memory, and I haven't had my coffee yet.
Was This Post Helpful? 1
  • +
  • -

#4 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6221
  • View blog
  • Posts: 21,475
  • Joined: 05-May 12

Re: Assert.Pass("Nothing to test yet")

Posted 11 April 2018 - 10:39 AM

Unit tests should be quick tests of the component independent of outside dependencies. Integration tests should test how the components interact with each other. Unit tests should not be integration tests.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1