Support explicitly disposing test dependencies
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 30/100
Línea de trabajo
Comienza revisando las opciones Add(Async)TestBlock y Add(Async)FinallyBlocks y, a continuación, examina el comportamiento de TestCase descrito en el issue. Un cambio completado debe establecer y documentar un enfoque de eliminación que limpie de forma fiable los contextos de navegador de Playwright de cada prueba y posiblemente los navegadores, sin ocultar dependencias.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Traditionally, we don't use dependency injection for objects that need to be explicitly disposed (e.g. rest clients that we want to stick around for all tests to reuse.) They are handled as part of the unit test method lifecycle using unit test setup/teardown. This works fine in most cases, but has always been kinda shaky as it can easily break the TestFramework concept of not hiding dependencies away.
However, we recently ran into a situation migrating a project from Selenium to Playwright, and had issues with how that project was managing disposable objects. Hooking playwright into the existing framework would involve a lot of effort, but Injecting the playwright disposables into DI doesn't properly work as we declare test dependencies as singletons so it doesn't reliably get cleaned up at the end of a test (playwright's instance is static, that may be the difficulty here.)
Consideration: For Playwright specifically, the parent Playwright object is okay to leave around for the entire test run, but we really want to destroy the browser context (and possibly the browser itself) between each run so that we're NOT just adding more open browsers on longer test runs.
Some possible fixes:
- Do nothing. Create a finally block to dispose the context (and possibly browser)
- Pro: It's easy and visible
- Con: for new projects someone will need to know to do this
- Possible mitigation:
- Update documentation and provide an example in the Examples project
- Write an analyzer that throws an informational message (already have other items that would be good for an analyzer, e.g. test blocks with no execute method.)
- Possible mitigation:
- Change or add Add(Async)TestBlock and Add(Async)FinallyBlocks that use a scoped lifetime.
- Pro: automagically handled
- Con: Could be unintentional behavior changes if we update existing methods, or would require someone to know the difference between scoped and singleton lifetimes (or what's disposable and what isn't) if we add new methods, which breaks the concept of not requiring and automated tester to know those specifics
- Possible mitigation:
- Four unique methods, something like Add(Async)DisposableTest(Finally)Block
- Just change the existing methods to use scoped instead of singleton
- Update the TestCase behavior to search through the container for any singletons that implement IDisposable and explicitly call them before going into the logic to throw any exceptions that occurred
- Possible mitigation:
- Lenguaje dominante
- C#
- Estrellas
- 1
- Forks
- 1
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de IntelliTect/TestTools.TestFramework
-
Create an analyzerAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
Playwright stack tracesAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 52/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
IntelliTect/TestTools.TestFramework#75 · 1 comentario ·
Todos los issues de IntelliTect/TestTools.TestFramework
Issues similares
-
bug next version
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Rem0o/FanControl.Releases#4220 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nkdAgility/azure-devops-migration-tools#3217 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
skoruba/Duende.IdentityServer.Admin#335 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
Los mantenedores suelen responder en 1 día
-
question
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100