Closed austincummings closed 9 years ago
can you share your test code?
Here you go,
import "package:unittest/unittest.dart";
import "package:redstone/server.dart" as app;
import "package:redstone/mocks.dart";
@app.Install(urlPrefix: "/ocams")
import "package:webquery/server/ocams.dart";
void main() {
app.setupConsoleLog();
app.setUp();
test("no parameters", () {
var req = new MockRequest("/ocams/hk/query", method: app.POST, body: {
"start_date": "1900-01-01",
"end_date": "2040-12-31"
});
return app.dispatch(req).then((resp) {
expect(resp.statusCode, equals(200));
});
});
app.tearDown();
}
Thanks! Try to move the setup() and tearDown() calls to the setup and teardown stages of your test:
import "package:unittest/unittest.dart";
import "package:redstone/server.dart" as app;
import "package:redstone/mocks.dart";
@app.Install(urlPrefix: "/ocams")
import "package:webquery/server/ocams.dart";
void main() {
setUp((){
app.setupConsoleLog();
app.setUp();
});
tearDown((){
app.tearDown();
});
test("no parameters", () {
var req = new MockRequest("/ocams/hk/query", method: app.POST, body: {
"start_date": "1900-01-01",
"end_date": "2040-12-31"
});
return app.dispatch(req).then((resp) {
expect(resp.statusCode, equals(200));
});
});
}
Works. Thanks!
Hey, I am receiving the following errors when I try to make a MockRequest to a route I have configured. All parameters should be set up correctly.