How to automatically create and run Regular Expression unit tests

DimonSmart 51 views 31 slides Aug 20, 2024
Slide 1
Slide 1 of 31
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31

About This Presentation

I'm creating my own C# TestAdapter for automated testing of regular expressions. Yes, I can run a test that doesn't exist!


Slide Content

REGEX TESTING BE LAZY – Automate everything!

Do you know what is Regular Expression?

Problem examples

Problem examples

Problem “solutions” examples

Problem “solutions” examples

https://adolfi.dev/blog/unit-testing-regex/

TRIZ on the rescue

Let the robots sweat, humans relax!

The ideal object is an object that does not exist, but its functions are performed. We do not write unit tests, but we can run them!

Magic. Step1. Let’s define a regex pattern.

Magic. Step2. Install magic Nuget 

Magic. Step3. Add positive test samples

Magic. Step3. Add negative test samples

Magic. Step3. Add Gray-ZONE test samples

DO Nothing & Get results!

Examples from test project

Invisible test  results!

Navigation!

Navigation route us directly to the source!

I saw an error on previous slide, show me!

Result details for free!

High-level details

1. Implement ITestDiscoverer

TestCase

2. Implement ITestExecutor

Results over everything

Curious fact with ITestExecutor ? Why SOLID is important?

ITestExecutor should be a bit ITestDiscoverer

https://github.com/DimonSmart/RegexUnitTester

How It All Started. ( DevDay : . NET (RUS) https://www.youtube.com/watch?v=HXSJQ6d4AE8