捕获ASP模板的输出以进行单元测试

时间:2009-07-08 16:20:26

标签: asp-classic

我正在尝试找到一种方法来捕获ASP模板的响应以用于测试目的。阅读this后,我希望以下代码能够提供解决方案:

class cMockResponse
    public data
    public sub write( value)
        if isempty(data) then data = ""
        data = data & value
    end sub
end class

class cView
    public response
    private sub class_initialize()
        set response = new cMockResponse
    end sub
    public sub render()
      ' expected that the following would be compiled to response.write "hello world"
      %> hello world <% 
    end sub        
end class

set view = new cView
call view.render()
response.write "the mock respone was:" & view.response.data   

考虑到我希望的博客文章

%> hello world <%

将简单地翻译为

response.write "hello world"

由于响应引用了模拟对象,我希望这个解决方案可以解决这个问题,但显然它没有。上面代码的输出不出所料:

hello world the mock response was:

是否有其他方法以编程方式捕获ASP模板的输出而无需借助内部xmlhttp请求?

1 个答案:

答案 0 :(得分:1)

据我所知,无法捕获输出。

如果您需要对经典ASP进行单元测试,可以查看ajaxed