DevAppServerTest @Rule problem

45 views
Skip to first unread message

Mariateresa Cava

unread,
Apr 16, 2019, 2:47:23 PM4/16/19
to Google App Engine

Hi,

I am having an issue using jUnit tests and handling exceptions in Java.

I created my testClass with both the annotations @RunWith(DevAppServerTestRunner.class) and @DevAppServerTest(TestConfig.class) since I need to test a method that use some properties configured in my appengine-web.xml file.

The problem comes when, after declaring a jUnit @Rule to define an Exception I want to test, I ran the test and got an error saying "The Rule myExceptionName must implement MethodRule or TestRule". That's pretty strange since the exception I declared is of type Expectedexception, a jUnit class tha already implements TestRule.

I suspect this issue has something to do with my @RunWith and @DevAppServerTest annotation because using another class without these the Rule implementation works(solution I can't use since I need to read some properties from appengine-web.xml).

Did anyone encounter something similar or have a clue on how to deal with this?

yka...@google.com

unread,
Apr 17, 2019, 5:26:42 PM4/17/19
to Google App Engine
I think it would be best to post this on Stackoverflow with a code snippet and the stack trace as it is better suited for technical development questions.

You can also check this doc for an example as well.

Mariateresa Cava

unread,
Apr 18, 2019, 9:33:59 AM4/18/19
to Google App Engine
Thank you for your support. I've already posted this on Stackoverflow. Anyone who has other suggestions?
Reply all
Reply to author
Forward
0 new messages