Skip to content

Commit

Permalink
add new test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
martinezmatias committed Nov 17, 2019
1 parent 7174f3f commit 169710a
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 1 deletion.
@@ -0,0 +1,36 @@
package RottenTestsFinder.FakePaperTests;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.junit.Test;

public class RTFRow30Skip extends AbstractRTestCase {
@Test
public void test0() {
int i = 10;
if (i > 0) {
return;
}
System.out.println("test");
}

@Test
public void test1() {
int i = 10;
if (i > 0) {
return;
}
fail("test");
}

@Test
public void test2() {
int i = 10;
if (i > 0) {
return;
}
assertTrue(i > 0);
}

}
@@ -1,3 +1,4 @@

package fr.inria.astor.test.repair.approaches;

import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -191,7 +192,7 @@ public void testRow04() throws Exception {
assertEquals("org.junit.Assert.assertTrue(4 > 1)", assertionNotExecuted.toString());

assertEquals(0, rottenTest0.getClassificationHelperAssertion().getResultNotExecuted().size());

assertEquals(0, rottenTest0.getClassificationHelperAssertion().getResultExecuted().size());

}
Expand Down Expand Up @@ -1501,6 +1502,72 @@ public void testRTFRow29() throws Exception {

}

@Test
public void testRTFRow30Skip() throws Exception {
RtEngine etEn = detectRtSkip();

List<TestInspectionResult> resultByTest = etEn.getResultByTest();
assertNotNull(resultByTest);

RuntimeInformation dynInf = etEn.computeDynamicInformation();

// First case: not executed a method inv
TestInspectionResult rottenTest0 = etEn.processSingleRest(dynInf,
"RottenTestsFinder.FakePaperTests.RTFRow30Skip", "test0");

assertNotNull(rottenTest0);

assertTrue(rottenTest0.getClassificationHelperCall().getResultNotExecuted().isEmpty());
// assertTrue(rottenTest0.getClassificationHelperAssertion().getResultNotExecuted().size()
// > 0);
assertTrue(rottenTest0.isRotten());

TestRottenAnalysisResult finalResult = rottenTest0.generateFinalResult();
assertTrue(finalResult.fullRottenHelperAssert.isEmpty());
assertTrue(finalResult.contextHelperAssertion.isEmpty());
assertTrue(finalResult.fullRottenAssert.isEmpty());
assertTrue(finalResult.fullRottenHelperCall.isEmpty());
assertTrue(finalResult.skip.size() > 0);

/// Fail
/// Should not be RT:
TestInspectionResult rottenTest1 = etEn.processSingleRest(dynInf,
"RottenTestsFinder.FakePaperTests.RTFRow30Skip", "test1");

assertNotNull(rottenTest1);

assertTrue(rottenTest1.getClassificationHelperCall().getResultNotExecuted().isEmpty());
// assertTrue(rottenTest0.getClassificationHelperAssertion().getResultNotExecuted().size()
// > 0);
assertTrue(rottenTest1.isSmokeTest());

finalResult = rottenTest1.generateFinalResult();
assertTrue(finalResult.fullRottenHelperAssert.isEmpty());
assertTrue(finalResult.contextHelperAssertion.isEmpty());
assertTrue(finalResult.fullRottenAssert.isEmpty());
assertTrue(finalResult.fullRottenHelperCall.isEmpty());
// We dont consider it as rt
assertTrue(finalResult.skip.isEmpty());

/// Assert
TestInspectionResult rottenTest2 = etEn.processSingleRest(dynInf,
"RottenTestsFinder.FakePaperTests.RTFRow30Skip", "test2");

assertNotNull(rottenTest2);

assertTrue(rottenTest2.getClassificationHelperCall().getResultNotExecuted().isEmpty());
assertTrue(rottenTest2.getClassificationAssert().getResultNotExecuted().size() > 0);
assertTrue(rottenTest2.isRotten());

finalResult = rottenTest2.generateFinalResult();
assertTrue(finalResult.fullRottenHelperAssert.isEmpty());
assertTrue(finalResult.contextHelperAssertion.isEmpty());
assertTrue(finalResult.fullRottenAssert.isEmpty());
assertTrue(finalResult.fullRottenHelperCall.isEmpty());
assertTrue(finalResult.skip.size() > 0);

}

private void checkFp(List<TestInspectionResult> tc, boolean toverif, String testname) {
Optional<TestInspectionResult> rotten01 = tc.stream().filter(e -> e.getTestMethodFromClass().equals(testname))
.findFirst();
Expand Down

0 comments on commit 169710a

Please sign in to comment.