farlee2121 / testingpatterns Goto Github PK
View Code? Open in Web Editor NEWThis project is to record and share patterns and libraries that make testing easier, descriptive and resilient
Home Page: https://20xtesting.slides.spencerfarley.com
This project is to record and share patterns and libraries that make testing easier, descriptive and resilient
Home Page: https://20xtesting.slides.spencerfarley.com
The idea here is to show how easy it should be to swap out data sources.
Could even base the persistence choice on configuration.
The idea is that all information needed to run a class is declared via the constructor.
This may seem like excess work and doesn't feel much different than things like Entity framework's configuration defaults.
However, trying to reuse a class outside of the DI setting shows complications. The component cannot be used without configuration that has no explicit ties. Knowledge of the ORM is required to understand why the code doesn't run. Further, configuration via a config file may not always be preferable.
By injecting connection strings, we make this dependency explicit. Within the DI setting, the configuration still happens automagically.
After a bit of research. It appears that MSTest allows you read the name when you extend test classes, but it does not allow you to modify it. This means i'll probably have to move to NUnit
Package app core as nuget packages so experimental UIs can be updated and independently from core framework
Are there tools and would it be meaningful to run generated tests against all possible input like in clojure.
The big issue here is understanding what the expected outcome for a set of inputs would be.
TestBase and the TestAccessor are both calling Database.EnsureCreated. Instead call to DataPrep, this way we don't even create a datastore is needed and centralize test storage type in one place.
This could also allow us to remove entityframework as a dependency in the test classes
Make it easy to test for simple free text vulnerabilities like special characters, sql injections, etc.
Could add a method to the builder that adds the text to every string type.
May want to look at running different theories (parameterized unit tests) for different vulnerabilities
Advice for porting to core
http://www.michael-whelan.net/porting-dotnet-framework-library-to-dotnet-core/
Analysis of this project
https://icanhasdot.net/result?github=farlee2121~2FTestingPatterns
Deep Equal has a PR for core support
jamesfoster/DeepEqual#23
Just mock recently planned core support
https://feedback.telerik.com/Project/105/Feedback/Details/240405-justmock-should-support-net-core
NUnit actually does have support, but it still has some special needs
https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard
Each service layer is responsible for a hiding/isolating a particular type of decision.
Accessors: third parties / stuff out of your control
Engines: calculations
Managers: composition of tasks
clients: program interaction
public class CreateWithSeedIfNotExists : CreateDatabaseIfNotExists<ApplicationDbContext>
{
protected override void Seed(ApplicationDbContext context)
{
}
}
Write some untested functions and unit tests to indicate they are untested
What is the right balance of data contract boundaries (DPL currently splits them for the DB, accessor, Managers/Engines, and Clients).
This helps bound changes & makes it easier to expose just the needed data, but results in a lot of data conversions and types. Adding a datatype turns into 5+ new files (migrations, data prep, and call chain types).
How can we reduce the burden of added types?
https://adrientorris.github.io/csharp/what-i-get-from-the-preview-of-csharp-8-with-Mads-Torgersen.html#extension_everything
dotnet/csharplang#110
C# will get extensions to instances that can add properties, instance methods, etc.
It may also get Type Classes (like interfaces, but instead of being part of the type definition it is more verified that the class fits the constraint)
What does this mean for my design?
Could I use extension to mimic AOP without dynamic proxies? I.e. extend all types with a log function. These log functions can be maintained separately and different ones can be used based on what log assembly is included? Hmm. This has a hole that I still need funnel info to the logger, which would require to accept the right info to pass on....
Anyway. Questions like that
Must be possible to find because code lens shows test references. It uses roslyn, which we can use too.
Enumeration to string mapping would solve issues with enumeration order and make the db more readable
Some items to note in readme files
The major question here is how to map back to the primitive with EF.
This would prevent extremely unpleasant refactoring in case of a need for change in id type. It also would enable some flexibility for multiple id types if necessary.
A builder could enable complex data creation while keeping each custom dimension more independent (fewer parameter in each signature, mix and match scenarios).
Bogus already works as a builder, but is very generic and requires relatively verbose configuration (*.RuleFor( prop => prop.Rulestuff...))
Key concerns.
Possible solutions
Before I wrote my own random value generators, so I just referenced them on dataPrep from all places. Now, I use bogus inside of dataprep. However, there are still cases where I want to generate random data outside of dataPrep (like object save_update tests). Do I expose Bogus and require all test assemblies to include Bogus, or do I hide bogus behind a custom class?
Should be able to create a fixture builder that reflects to fetch attributes on a method. Then, generate a test case (in the fixture builder) for both unit and integration unless an exclusion attribute is present.
https://www.red-gate.com/simple-talk/dotnet/net-tools/testing-times-ahead-extending-nunit/
https://stackoverflow.com/questions/39686622/nunit-get-tests-names-in-a-fixture
Create an experimental version of the app with F# to see how the architecture and patterns translate into a functional language.
Functional languages enforce many of the practices I use by convention. It may make sense to just switch.
Figure out how to replicate my unit/integration extension to nUnit with xUnit.
Also, instead (or in addition to?) adding to the test name, I can add traits to organize the test more hierarchically
http://www.brendanconnolly.net/organizing-tests-with-xunit-traits/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.