GithubHelp home page GithubHelp logo

fatihsahin / test-flask Goto Github PK

View Code? Open in Web Editor NEW
19.0 8.0 1.0 2.63 MB

TestFlask - A record-replay-assert testing framework and tools for .net

Home Page: https://testflask.github.io

License: MIT License

C# 96.87% PowerShell 0.74% CSS 0.65% ASP 0.02% JavaScript 1.72%
fody testing-tools test-framework scenario

test-flask's People

Contributors

fatihsahin avatar gitter-badger avatar sahinunlu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

gitter-badger

test-flask's Issues

Dynamic playback marking

A visual studio extension can be implemented to mark methods with Playback functionality on VS editor. Marked methods with proper identifier can be persisted to a xml file and weaver can rely on this file to weave methods

Cascade response updates using declared matching strategy

When a response is being updated for a invocation, user can declare cascading options. For example user can trigger the update for all responses with matching depth, sibling, request or signature inside the step, with matching request or signature inside a scenario or whole project with a single update action.

Update Fody version

Upgrade TestFlask to use new Fody version. New Fody licence is asking package consumers to be a patreon. TestFlask can contain its own plugin to Ms Build and therefore there would be no need for Fody. Worth considering.

Support IntelliRecord mode on cross service requests

As invocations are cleared before hand on initial service root depth, cross service cannot find matching invocation to replay in intellirecord mode even if the invocation was marked as replayable. Consider an alternative solution to clearing all invocations. Each service may manage its ow invocations inside a step, a service key should be introduced in configuration for services

Generic identifier compiler problem

For generic methods, we cannot define a generic attribute. It is not allowed in C#. Therefore it makes sense to declare an identifier like below with an object type for generic args.

public class GetGenericReqIdentifier : IRequestIdentifier<object, FooRequest>
{
	public string ResolveDisplayInfo(object arg0, FooRequest arg1)
	{
		return "ooh";
	}

	public string ResolveIdentifierKey(object arg0, FooRequest arg1)
	{
		return "whaaat";
	}
}

However, testFlask weaver generates something like

[Playback(typeof(GetGenericReqIdentifier), null)]
public TRes GetSomeGeneric<TReq, TRes>(TReq req, FooRequest fooReq) where TRes : new()
{
	FuncPlayer<TReq, FooRequest, TRes> funcPlayer = new FuncPlayer<TReq, FooRequest, TRes>
("TRes AssemblyToProcess.SomeClient`1::GetSomeGeneric(TReq,AssemblyToProcess.FooRequest)", 
		new GetGenericReqIdentifier(), null);
	//the rest of body
}

which generates a compiler error that is Argument 2: cannot convert from 'AssemblyToProcess.GetGenericReqIdentifier' to 'TestFlask.Aspects.Identifiers.IRequestIdentifier<TReq, AssemblyToProcess.FooRequest>'.

TestFlask must support generic identifier implementations

Gather played invocation call tree

While playing a current step, current played invocation tree can be gathered just like in record mode. This tree can be used to log or report a difference between recorded tree and replayed one. Also unmatched invocations can be marked to alert changes in play

CI integration with CLI tooling

A CLI tool can be written to run a console app to trigger recorded steps by actually calling TestFlask ready backend service host to support regression testing automation. Console app can stream errors to ErrorOutputStream, so a defined TFS build task can plug in and fail the entire build process if any assertions fail

New TestFlask mode - IntelliRecord

Introduce a new testflask mode like IntelliRecord/HybridRecord. When testFlask is set to this mode, inner player will record unmatched invocations as new and call original record wrapper, yet it will reuse recorded responses for matching invocations. Therefore it will be possible to record a diff patch to reduce the cost of setting up integration environments for re-recording. Only newly introduced integration nodes need to be online.

unit test documentation

auto generated unit test methods can have summary doc sections feeded from scenario and step descriptions

Java version for TestFlask

This is a very early brainstorming. Java services can be manipulated using maybe Javassist and a maven task plugged in for javassist

Add dynamic pattern matching strategy

When an invocation is requested from TestFlask API, currently it uses invocation instance hash code to fetch single invocation. Invocation instance hash code is a composite hash code to define a invocation instance uniquely inside the whole recorded call tree. However, different invocation matching strategies can be used such as using signature hash code, signature+request identifier hash code, and depth hash code. That way TestFlask could return same response for methods with same signature, same signature with same request identifier or same signature+request identifier on same depth level. This way api could return another invocation response and it may help regression tests to be independent from call stack tree changes. Strategy can be set on many levels including on project level, scenario level and step level. Lower levels would be dominant.

weave generic methods

testFlask should be able to weave generic methods such as
public TRes DoSomething<TReq1, TReq2, TRes>(TReq1 req1, TReq2 req2, int someOtherParam) { }

Get rid of HttpContext.Current

HttpContext.Current is blocking migration to .net core. It also disables support for async call interceptions. I will use a static Dictionary and keep it simple. In async calls they will be directly appended to root call. In sync calls to distinguish initial invocation from childs or siblings I plan to mark initial invocation with sth like [Playback(IsRoot: true)]. A timer thread with some idle time configuration may clean up static dictionary after a recording session is complete and override the scenario if IsRoot:true invocation is recorded again or replayed.

Support for weaving async methods

Create a POC branch for weaving async functions that returns Task or Task<T>. TestFlask context (such as depth, invocation index or hierarchy) can be synced with continuation tasks that are appended inside player. HttpContext may or may not be available inside thread pool. An alternative solution can be necessary. Also consider what can be done with async void methods

Patch invocations to a step

An invocation totally declared from scratch or cloned from other step invocation trees can be patched to an existing invocation tree to make steps more flexible to react to underlying service version/implementation changes. UI Views can be implemented in test-flask-web repo, or a new rich client (like WPF maybe?) can be implemented for specific patching/cascading variations.

Add request replacement variables on different levels

Users can define variables on project, scenario and step levels to replace any part of their recorded root request to be dynamically replaced with variable values. Moustache style {{variableName}} can be preffered. By altering variable values, request can be dynamically modified before any assertion or playback. This could help to trigger some secure service or apis with changing token or user credentials or with custom soap or http headers, idempotency keys etc.

Cloning a scenario

Scenario cloning is currently not implemented. A clone should update stepno and scenariono containing fields in whole scenario object tree as well as variables to be cloned to the new scenario

Resolve evaluated variables

Some variables can have a basic C# snippet to resolve the value in runtime. While declaring a variable, we can use the value field to store expression and a IsEvaluated flag to determine whether this is a static value or must be evaluated. Probably a very basic C# compiler would work and there is no need to support advanced syntax like LINQ at the beginning. It would be great if expression like this works => System.DateTime.Now.ToString("dd.MM.yyyy")

Auto-generated unit tests

A side TestFlask project potentially could auto generate unit tests to trigger each scenario as a seperate test method. Generator can use root invocation request object and method signature to set up the test. It could also use expected assertion object to truly assert the output. It could help increasing the test code coverage.

Labeling scenarios

Scenarios can have one or more labels to categorize the scenario trair explicitly. Unit test generator tool or other complementary features can rely on these labels to use the scenario or not in their specific context

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.