From 5bde9394d90b8720e3117a7601941388f9b47632 Mon Sep 17 00:00:00 2001 From: danglotb Date: Tue, 26 Nov 2019 15:10:41 +0100 Subject: [PATCH] test: unit test the support by Junit3 of the two assert class --- .../test_framework/TestFrameworkTest.java | 18 ++++++++++++++++++ .../fr/inria/helper/SecondClassJUnit3.java | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/dspot/src/test/java/eu/stamp_project/test_framework/TestFrameworkTest.java b/dspot/src/test/java/eu/stamp_project/test_framework/TestFrameworkTest.java index 4036c0354..e920a6d63 100644 --- a/dspot/src/test/java/eu/stamp_project/test_framework/TestFrameworkTest.java +++ b/dspot/src/test/java/eu/stamp_project/test_framework/TestFrameworkTest.java @@ -30,6 +30,24 @@ private CtMethod findAndRegister(String ctClass, String methodName) { return testExpectingAnException; } + @Test + public void testJUnit3TestFrameworkSupportsTwoAssertClasses() { + /* + The test framework for junit 3 should recognized both class as assert class: + - junit.framework.TestCase + - junit.framework.Assert + */ + + CtMethod testJUnit3 = this.findMethod("fr.inria.helper.SecondClassJUnit3", "testUsingDeprecatedAssertClass"); + System.out.println(testJUnit3); + assertTrue(TestFramework.get().isTest(testJUnit3)); + assertTrue(TestFramework.get().isAssert(testJUnit3.getBody().getStatement(0))); + testJUnit3 = this.findMethod("fr.inria.helper.SecondClassJUnit3", "test"); + System.out.println(testJUnit3); + assertTrue(TestFramework.get().isTest(testJUnit3)); + assertTrue(TestFramework.get().isAssert(testJUnit3.getBody().getStatement(0g))); + } + @Test public void testGenerateAfterClassToSaveObservations() { diff --git a/dspot/src/test/resources/sample/src/test/java/fr/inria/helper/SecondClassJUnit3.java b/dspot/src/test/resources/sample/src/test/java/fr/inria/helper/SecondClassJUnit3.java index e3d936383..55f923f81 100644 --- a/dspot/src/test/resources/sample/src/test/java/fr/inria/helper/SecondClassJUnit3.java +++ b/dspot/src/test/resources/sample/src/test/java/fr/inria/helper/SecondClassJUnit3.java @@ -1,6 +1,7 @@ package fr.inria.helper; import junit.framework.TestCase; +import junit.framework.Assert; public class SecondClassJUnit3 extends TestCase { @@ -27,4 +28,8 @@ public void testExpectingAnException() { throw new RuntimeException(); } + public void testUsingDeprecatedAssertClass() { + Assert.assertEquals(3, 3); + } + }