Prototype of idea to write/execute tests of code classes from browser. The solution based on System.Reflection
to collect the testing data of target assembly.
- Properties
- Constructors
- Fields
- Methods
- Create NuGet package from
Scenario
project. - Add a reference to the newly created NuGet package to your solution.
- Configure
Startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider diService)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseScenario();
app.UseHttpsRedirection();
app.UseMvc();
}
- Setup your testable classes using data annotations as described below.
- Run solution.
[ScenarioActivation(ActivationMode)]
enables your class or its members to be included in tests.
Three ActivationMode
are available:
ActivationMode.All
includes entire classActivationMode.Single
includes selected memberActivationMode.None
exlcludes selected member (can be combined withActivationMode.All
)
[ScenarioDescription(System.String, System.String)]
adds description what class represents of.
The test creation consists of three actions:
- Assign – create a named variable
- Execute – create a new object instance or invoke method
- Assert – compare an actual result and expected one
This page is pretty simple and shouldn't cause any problem.