English 中文(简体)
g 铁路:如何用多种行动和多种后向来测试控制器?
原标题:grails: how to test controller with multiple actions and multiple redirects?

i am having the following problem: i want to test the logout action of my controller. before that i am calling the login method of my controller which both redirect to the same page. now I am getting the following error message:

groovy.grails.web.servlet.mvc.exceptions.CannotRedirectException: Cannot issue a redirect(..) here. A previous call to redirect(..) has already redirected the response.

i 确实理解这一问题,但所有建议的解决办法(回顾重整方法;叫GrailsWebUtil.bindMockWebRequest())都没有奏效。

i am doing integration testing and using the class ControllerUnitTestCase.

any suggestions? thanks dominik

问题回答

OK, I found the answer(s):

  1. 我不得不说这套话。 从超级班到:

    @Before
    void setUp() {
        super.setUp()
    
  2. You cannot call reset() if you want to keep your session because it also clears your session. Call instead:

    redirectArgs.clear()
    

Cheers, Dominik





相关问题
Selenium not working with Firefox 3.x on linux

I am using selenium-server , selenium rc for UI testing in my application . My dev box is Windows with FireFox 3.5 and every thing is running fine and cool. But when i try to run selenium tests on my ...

Best browser for testing under Safari Mobile on Linux?

I have an iPhone web app I m producing on a Linux machine. What s the best browser I can use to most closely mimic the feature-limited version of Safari present on the iPhone? (It s a "slimmed down" ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Is there any error checking web app cralwers out there?

Wondering if there was some sort of crawler we could use to test and re-test everything when changes are made to the web app so we know some new change didn t error out any existing pages. Or maybe a ...

热门标签