I am somewhat disappointed that JUnit5 is less predictable...

On Tue, Apr 17, 2018 at 10:35 AM, Niclas Hedhman <nic...@hedhman.org> wrote:

>
> For a while I thought the problem is that there is a hierarchy of abstract
> tests, and that there is 2 levels of inheritance between the MongoDb test
> and the AbstractPolygeneBaseTest, but IF I do the following test, it works
>
>
> import org.junit.jupiter.api.Assertions;
> import org.junit.jupiter.api.BeforeEach;
> import org.junit.jupiter.api.Test;
>
> public class Tests
> {
>     public static class BaseTestClass {
>
>         @BeforeEach
>         public void setUp(){
>             System.out.println("Base Test Class");
>         }
>     }
>
>     public static class InheritsFromBase extends BaseTestClass {
>
>     }
>
>     public static class InheritsFromBase2 extends InheritsFromBase {
>
>     }
>
>     public static class ActualTests extends InheritsFromBase2 {
>
>         @Override
>         @BeforeEach
>         public void setUp() {
>             System.out.println("I inherit from base");
>
>             super.setUp();
>         }
>
>         @Test
>         public void myTest(){
>             Assertions.assertTrue( true );
>         }
>     }
> }
>
>
> On Tue, Apr 17, 2018 at 10:09 AM, Niclas Hedhman <nic...@hedhman.org>
> wrote:
>
>>
>> Gang,
>> if anyone has extensive experience with JUnit5, is there any explanation
>> that
>>
>>
>> @Override
>> @BeforeEach
>> public void setUp()
>>     throws Exception
>> {
>>     super.setUp();
>>
>>
>> will not be called when running the test, but if I change it to
>>
>>
>> @BeforeEach
>> public void setUp2()
>>     throws Exception
>> {
>>     super.setUp();
>>
>>
>> It will be called?
>>
>> The super-class's method is
>>
>> @BeforeEach
>> public void setUp()
>>     throws Exception
>> {
>>     polygene = new Energy4Java();
>>
>>
>>
>>
>> And IF I change to setUp2(), then the setUp() in the super class IS
>> called directly by junit platform engine.
>>
>> Cheers
>> --
>> Niclas Hedhman, Software Developer
>> http://polygene.apache.org - New Energy for Java
>>
>
>
>
> --
> Niclas Hedhman, Software Developer
> http://polygene.apache.org - New Energy for Java
>



-- 
Niclas Hedhman, Software Developer
http://polygene.apache.org - New Energy for Java

Reply via email to