I have already gone through this solution : Struts 2 JUnit Plugin v2.2.3: Test Class Extending StrutsTestCase; 'request' is null
But I\'m already not having
To avoid request from being null:
request = new MockHttpServletRequest();
For session:
Map<String, Object> sessionMap = new HashMap<String, Object>();
actionProxy.getInvocation().getInvocationContext().setSession(sessionMap);
If you are using getActionProxy method to execute your actions then you need to set new session map into the invocation context.
ActionProxy actionProxy = getActionProxy("/action");
Map<String, Object> sessionMap = new HashMap<String, Object>();
actionProxy.getInvocation().getInvocationContext().setSession(sessionMap);
actionProxy.execute();
If you don't need reference to action proxy then you can use executeAction method. Note that executeAction will return actual output of the result, not the result returned from execute method.
In my case I needed to call super.setUp from my test.