GithubHelp home page GithubHelp logo

cottsak / controllertests Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 3.0 1.45 MB

A package to simplify end-to-end testing for MVC and WebApi controllers while supporting legacy db schemas.

C# 93.44% CSS 0.46% JavaScript 5.49% PowerShell 0.61%

controllertests's People

Contributors

cottsak avatar

Stargazers

 avatar

Watchers

 avatar

controllertests's Issues

Include embedded store helpers

Like LocalDb, InMemoryEventStore and one for RavenDB if it adds something to RavenDB.Embedded.

There should be examples that show how to set up different types of embedded stores and they should reference these helpers.

Allow arbitrary headers to be added to an api request

When I have this:

var response = Get("/api/whatisyourname");

I would like to have this too (or something similar):

var response = Get("/api/whatisyourname", headers: { {"dev", "fosdfnsoajfnaosdj" } });

I have a need to send headers into requests.

Add the OnRelease() back

Rob suggested to .Flush() and .Clear() inside the Post() helper thus simulating the OnRelease() behaviour. We could even reuse the delegate passed into OnRelease() so that it's not duplicated in the test.

First class support for NUnit

Currently the life cycle management that's baked into this library works well with the way xunit does things however NUnit is different. Internal instances leak from test to test when using NUnit so it would be great to see some first class support for NUnit.

Does it make sense to allow any top-level type, not just Controllers?

Some MVC work means that the controller is not the entry point: think BaseController or BasePage - things that are used directly on views, particularly layouts. Since these don't have a specific controller action entry point, how do we test these?

Does it make sense to expand this framework to allow the SUT to be any type/interface such that the ActAction()/InvokeAction() can be called against any method and still have a 'real' IoC container integrate the test completely down to the real database? This way we could pull out an interface used in say BaseController, test one of it's methods and expect the rest of the dependencies to be real and integrated against the real db. Or does this move too far from the notion of a Subcutaneous Test? One could argue that in the spirit of Subcutaneous Testing we're ok, because we're still trying to stay as close to the surface as pragmatically possible.

Does it make sense to unbind a test class from only the one Controller?

Like is suggested in #6, some tests may need to invoke more than one controller action. If this is true it's likely those two or more actions are not from the same controller. As it is currently designed, this infrastructure does not support that scenario. Perhaps it makes sense to allow the InvokeAction() method to specify a generic argument for any controller thus giving th test a lot more flexibility?

Rename back to InvokeAction()

The 5a0aa8b means that a test might only have one controller call which is fairly limiting.

The set up of a test may need to get some result from a different controller call and therefore InvokeAction() instead of ActAction() seem more appropriate. Tests like this (multiple controller calls) are more complete in terms of real user interaction anyway so should be encouraged not discouraged.

Consider removing the NCrunch attribute

Implementers can simply use a base type for tests that need to use only a single thread for certain tests, and decorate that type if they use NCrunch. This package shouldn't force a dependency on NCrunch for everyone.

For example, using EmbeddableDocumentStore, I don't need to worry about the threading issue as the tests can run in parallel - everything is setup and torn down inside each test. I don't have the "transaction" concerns of SQL store tests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.