Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mutate: assess assertions in test code #1113

Open
christoffer-nylen opened this issue May 13, 2020 · 0 comments
Open

mutate: assess assertions in test code #1113

christoffer-nylen opened this issue May 13, 2020 · 0 comments

Comments

@christoffer-nylen
Copy link
Collaborator

christoffer-nylen commented May 13, 2020

Assume

  • The user assesses test quality by ensuring that each test kills some mutant.
  • The user has written a test case that contains both correct and incorrect assertions.
  • When running mutation testing, some assertions kill mutants.

Problem: Incorrect assertions will not be detected.

Example 1: Incorrect test evaluation

EXPECT_EQ(some_actual_value_returned_from_the_sut, some_expected_value_set_by_the_test); // OK
EXPECT_EQ(some_expected_value_set_by_the_test, some_expected_value_set_by_the_test); // NOT OK

Example 2: Incorrect pre-condition evaluation

ASSERT_EQ(some_pre_condition, some_pre_condition); // NOT OK

Example 3: Overgenerelized test code

if (some_cond) {
  EXPECT_EQ(...); // Is this executed?
}
if (some_other_cond) {
  EXPECT_EQ(...); // Is this executed?
}
if (some_third_cond) {
  EXPECT_EQ(...); // Is this executed?
}

Example 4: Complex test code

for (cond){
  for (cond) {
    if (some_cond) {
      if (some_other_cond) {
        if (some_third_cond) {
          EXPECT_EQ(...); // Is this executed?
        } else
          EXPECT_EQ(...); // Is this executed?          
        }
      }
    }
  }
}

Example 5: Test code that can be removed

// TODO: Remove depricated EXPECT_EQ when feature X is removed
Feature_X = getDepricatedFeature();
if (Feature_X.active == True){
  EXPECT_EQ(...); // Is this executed?
}

Suggestion:

Add functionality that lets the user verify that each assertion in the test is able to detect a bug.

@christoffer-nylen christoffer-nylen changed the title mutate: show good/bad assertions in test code mutate: enable assessment of good/bad assertions in test code May 13, 2020
@christoffer-nylen christoffer-nylen changed the title mutate: enable assessment of good/bad assertions in test code mutate: assessment of good/bad assertions in test code May 13, 2020
@christoffer-nylen christoffer-nylen changed the title mutate: assessment of good/bad assertions in test code mutate: assess assertions in test code May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant