restjunitexecutenosuchmethod

why does StrutsJunit4TestCase invoke the execute() method in a struts rest configured web application?


I recently write a web application with Struts2 REST, and I ran the junit test for a Action class then I got an error:

java.lang.NoSuchMethodException: cn.fshk.stock.struts.biz.admin.AuthorizationController.execute()

But it seems to run correctly in Tomcat.

Dose it suppose to invoke the index() method in a Struts2 REST controller?

Can anyone give me some help?


Solution

  • ok, I find out what's wrong.

    I need to add

        request.setMethod("GET");
    

    before

        excuteAction("...");