0

enter image description hereI am trying to kill a conditional Mutation, below is my code

   public String check(Integer value) {


    String valueStr = String.valueOf(value);
    String value2;
    if (valueStr.length() > 2) {
        value2 = valueStr.substring(valueStr.length() - 2);
    } else {
        value2 = valueStr;
    }

    return value2;

}

My test has

package com.example.demo;

    import org.junit.jupiter.api.Assertions;
    import org.junit.jupiter.api.Test;
    
    public class RunTest {
    
    
    @Test
    public void run(){
    
          Run r=new Run();
    Assertions.assertEquals(2,r.check(123).length());
    
    Assertions.assertEquals(2,r.check(12).length());
    
    Assertions.assertEquals(1,r.check(1).length());
        }
    }

I am not able to kill the mutation.I am getting 1. changed conditional boundary → SURVIVED

Thejas
  • 379
  • 5
  • 24
  • No this is the not the actual code, The input for the code is ie Integer intvalue=123 is dynamic just for sake of explanation I have hardcoded it to 123 – Thejas Aug 14 '21 at 08:21
  • @Seelenvirtuose I have updated my question with the minimal reproducible code thank you – Thejas Aug 14 '21 at 08:41
  • But the mutation coverage is 0 – Thejas Aug 14 '21 at 08:52
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/235990/discussion-between-thejas-and-seelenvirtuose). – Thejas Aug 14 '21 at 08:53

0 Answers0