テストが機能しない理由が見つかりません。なぜそれが起こるのか知っている人はいますか?これら 2 つのテストの違いはビューのみです。最初は「.html」ページで、2 番目は「.liquid」です。私のプロジェクトでは「.liquid」を使用しているため、「.html」は正しい動作テストをテストするためだけのものです。私はナンシーモジュールを持っています
public sealed class Module : NancyModule
{
public Module(IBackend storage)
{
Get["/"] = _ => View["Create.liquid"];
Get["/Test"] = _ => View["TestHtml.html"];
}
}
そしてテスト
[Test]
public void test_html()
{
// Given
var bootstrapper = new ConfigurableBootstrapper(with =>
{
var module = new Module(new Endpoint());
with.Module(module);
});
browser = new Browser(bootstrapper);
// When
var result = browser.Get("/Test", with =>
{
with.HttpRequest();
});
// Then
Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
}
[Test]
public void test_liquid()
{
// Given
var bootstrapper = new ConfigurableBootstrapper(with =>
{
var module = new Module(new Endpoint());
with.Module(module);
});
browser = new Browser(bootstrapper);
// When
var result = browser.Get("/", with =>
{
with.HttpRequest();
});
// Then
Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
}
二次試験で例外あり
System.Exception : ConfigurableBootstrapper Exception
----> Nancy.RequestExecutionException : Oh noes!
----> Nancy.ViewEngines.ViewNotFoundException : Unable to locate view 'Create.liquid'
Currently available view engine extensions: sshtml,html,htm
Locations inspected: ,,,,,,,,views/Module/Create.liquid-en- US,views/Module/Create.liquid,Module/Create.liquid-en-US,Module/Create.liquid,views/Create.liquid-en-US,views/Create.liquid,Create.liquid-en-US,Create.liquid
Root path: D:\Projects\epm-vsp-pasta\Tests\bin\Debug
スタック トレースあり
at Nancy.Testing.PassThroughStatusCodeHandler.Handle(HttpStatusCode statusCode, NancyContext context) in d:\Nancy-master\src\Nancy.Testing\PassThroughStatusHandler.cs: line 22
at Nancy.NancyEngine.CheckStatusCodeHandler(NancyContext context) in d:\Nancy-master\src\Nancy\NancyEngine.cs: line 219
at Nancy.NancyEngine.HandleRequest(Request request, Func`2 preRequest) in d:\Nancy-master\src\Nancy\NancyEngine.cs: line 112
at Nancy.NancyEngine.HandleRequest(Request request) in d:\Nancy-master\src\Nancy\NancyEngine.cs: line 77
at Nancy.Testing.Browser.HandleRequest(String method, String path, Action`1 browserContext) in d:\Nancy-master\src\Nancy.Testing\Browser.cs: line 125
at Nancy.Testing.Browser.Get(String path, Action`1 browserContext) in d:\Nancy-master\src\Nancy.Testing\Browser.cs: line 62
at Tests.TestModule.test_liquid() in TestModule.cs: line 111 --RequestExecutionException
at Nancy.NancyEngine.InvokeOnErrorHook(NancyContext context, ErrorPipeline pipeline, Exception ex) in d:\Nancy-master\src\Nancy\NancyEngine.cs: line 272
--ViewNotFoundException