Inheritance with jnario

56 views
Skip to first unread message

Christian Braun

unread,
Nov 21, 2014, 11:35:10 AM11/21/14
to jna...@googlegroups.com
Hi guys,

I'm a student working with jnario for my professor. I really like it so far. But now I've got the problem, that I don't know how to inherit from a super class.
I want to inherit from an abstract super class wich contains @Before @After annotations aswell as protected methods.
I know that I can easily get access to basic tear down methods by using an extension. But I wasn't able to find out how to use the protected methods.
Is this just working through the implicit subject?
I appreciate every answer, but please keep in mind that I just started with jnario.

Best regards

Christian

Sebastian Benz

unread,
Nov 24, 2014, 7:47:02 AM11/24/14
to jna...@googlegroups.com
Hello Christian,

this is actually was spec extension are for, but I am not exactly sure what you are trying to achieve with the protected methods? 

Cheers,

Sebastian


--
You received this message because you are subscribed to the Google Groups "Jnario" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jnario+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christian Braun

unread,
Nov 28, 2014, 6:00:31 AM11/28/14
to jna...@googlegroups.com
Hello Sebastian,

thanks for your reply.

I'll give you an example.

public abstract class AbstractPage extends NormalPage{
    ...
    ...
    @Override
    protected int pageElements(AbstractPage page){
        ...
        ...
        ...
    }
}

I want to achieve something like this

public class PageStuff extends AbstractPage{
    ...
    ...
    int pageElementsOfThisPage;
   
    public PageStuff()    {
        this.pageElementOfThisPage = this.pageElements;
    }
}


When I'm trying to do this with Jnario

//extension static AbstractPage; //can't inherit from Abstract classes
extension static NormalPage = new NormalPage // works but pageElements isn't visible in spec
fact "foo"{
   pageElements();  //here it says pageElements isn't visible.
}

Maybe you can understand me now a little bit better.


Best regards
Christian

Sebastian Benz

unread,
Nov 30, 2014, 2:21:53 PM11/30/14
to jna...@googlegroups.com
You can use the @Extends annotation  to define super classes for your specs. 

Does these solve your problem?

Sebastian


Christian Braun

unread,
Dec 5, 2014, 6:54:38 AM12/5/14
to jna...@googlegroups.com
Hi Sebastian,

yes that solved it!
Thank you very much.

Best regards
Christian
Reply all
Reply to author
Forward
0 new messages