Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Testing

  • concat isn't a great name for a test, it doesn't tell me anything about what it is that the test does, it simply copies the name of the method being called. Something like concatShouldReturnConcatenationForTwoPopulatedArrays might be a better description

  • Personally, for a test this simple, I'd tend to define the expected results for the test within it rather than calculating it on the fly. This makes it less likely that you'll get a failure because your test is wrong. It also allows you to use the junit array comparison junit array comparison.

     Assert.assertArrayEquals( expectedResult, result );
    
  • You've only got one test, I'd tend to add at least 3 more for:

     concat([], numbers2)
     concat(numbers1, [])
     concat([], [])
    

Testing

  • concat isn't a great name for a test, it doesn't tell me anything about what it is that the test does, it simply copies the name of the method being called. Something like concatShouldReturnConcatenationForTwoPopulatedArrays might be a better description

  • Personally, for a test this simple, I'd tend to define the expected results for the test within it rather than calculating it on the fly. This makes it less likely that you'll get a failure because your test is wrong. It also allows you to use the junit array comparison.

     Assert.assertArrayEquals( expectedResult, result );
    
  • You've only got one test, I'd tend to add at least 3 more for:

     concat([], numbers2)
     concat(numbers1, [])
     concat([], [])
    

Testing

  • concat isn't a great name for a test, it doesn't tell me anything about what it is that the test does, it simply copies the name of the method being called. Something like concatShouldReturnConcatenationForTwoPopulatedArrays might be a better description

  • Personally, for a test this simple, I'd tend to define the expected results for the test within it rather than calculating it on the fly. This makes it less likely that you'll get a failure because your test is wrong. It also allows you to use the junit array comparison.

     Assert.assertArrayEquals( expectedResult, result );
    
  • You've only got one test, I'd tend to add at least 3 more for:

     concat([], numbers2)
     concat(numbers1, [])
     concat([], [])
    
Source Link
forsvarir
  • 11.8k
  • 7
  • 39
  • 72

Testing

  • concat isn't a great name for a test, it doesn't tell me anything about what it is that the test does, it simply copies the name of the method being called. Something like concatShouldReturnConcatenationForTwoPopulatedArrays might be a better description

  • Personally, for a test this simple, I'd tend to define the expected results for the test within it rather than calculating it on the fly. This makes it less likely that you'll get a failure because your test is wrong. It also allows you to use the junit array comparison.

     Assert.assertArrayEquals( expectedResult, result );
    
  • You've only got one test, I'd tend to add at least 3 more for:

     concat([], numbers2)
     concat(numbers1, [])
     concat([], [])
    
lang-java

AltStyle によって変換されたページ (->オリジナル) /