Junit testing in methods

Hi friends . Am working on a certain ticket related to testing methods and came up with a question is it possible to write test using if statements like this My worry after writing this would be would it be under better testing methods and java convetions Assummig you have this forexample inside your methods

  1. @Test
  2. Public void dateFormat_shouldReturnFalseWhenDateIsNull(){
  3. Date date = null;
  4.  try {
  5.  }
  6. if() {
  7. date=null;
  8. }
  9. }catch(ParseException ex) {
  10. ex.printStackTrace();
  11. } 14.if(!date==null) {
  12. 	AssertTrue("expectations");
  13. }else {
  14. AssertFalse("expecations");
  15. }
  16. }

Any help and clarification will be highly appreciated @dkayiwa, @mozzy

The scenario you are describing is a bit vague…perhaps u can throw more light on what u are doing exactly including the class and the method u are testing plus the ticket

Did you read and try to figure out what am trying to bring out on the other hand. Using if statements and in the place of catching the exception, add the test formulae, i.e assertsTrue and assertFalse are seen in if statement closes .thats what I meant I hope you got it right man

@sharif can you please correct your grammer and pacntuation ??

@sharif can you please describe properly what your trying to do …i think i also done undertsand

My aim here is whether it was possible to add assertions in if statements and i hope it made sense after updating it actually finally i got it. though thanks @mozzy and @reagan

i wouldnt expect an if statement when writing test units idealy , remember whenyou’re writing test units, your only testing already written Logic whether it behaves as expected. I dont again expect you writing again Logical statements when testing written Logic :slightly_smiling_face: