Saltar al contenido

ejemplo de código de marco de pruebas basado en datos

Este team de expertos despúes de algunos días de investigación y de recopilar de información, hemos dado con la solución, queremos que te resulte útil en tu trabajo.

Ejemplo 1: ¿cómo se implementan las pruebas basadas en datos en el marco?

HOWDOYOUIMPLEMENTDATADRIVENTESTINGINYOURFRAMEWORK?TESTNG:1. @DataProvider annotation
	2.Excel file with the help ofApachePOI3.JSON or CSV file forAPI testing
	4.Data which comes fromDatabase and stores in collections

	To use the DataProvider feature in the test cases, 
    you have to declare a method annotated by @DataProvider
    and then use the said method in the test method
    using the ‘dataProvider‘ attribute
    in the @Test annotation.CUCUMBER/JUNIT:1.Scenario outline
	2.Excel file with the help ofApachePOI3.JSON or CSV file forAPI testing
	4.Data which comes fromDatabase and stores in collections
	5. @ParameterizedTest-->If you use JUnit-5ExamplesforParameterizedTest:

	@ParameterizedTest
    @ValueSource(ints =1,2,3,4)==>
    it can be ints/strings/booleans/chars(those are keywords)publicvoidvalidateRegionNameTest1(int id)
     xxxxx
    

    @ParameterizedTest
    @CsvSource("1, Europe","2, Americas","3, Asia","4, Middle East and Africa")publicvoidvalidateRegionNameTest2(int id,String name) 
    xxxx
    

    @ParameterizedTest
    @CsvFileSource(resources ="/regions.csv")

    @ParameterizedTest(name ="index => a=0, b=1, sum=2")
    @MethodSource("sumProvider")
  
    @ParameterizedTest(name ="index => pet=''0''")
    @EnumSource(value =Pet.class, names ="CAT")

    @ParameterizedTest(name ="index => a=0, b=1, sum=2")
    @ArgumentsSource(CustomArgumentProvider.class)

Ejemplo 2: marco de pruebas basado en datos

HOWDOYOUIMPLEMENTDATADRIVENTESTINGINYOURFRAMEWORK?TESTNG:1. @DataProvider annotation
	2.Excel file with the help ofApachePOI3.JSON or CSV file forAPI testing
	4.Data which comes fromDatabase and stores in collections

	To use the DataProvider feature in the 
    test cases, you have to declare a method
    annotated by @DataProvider and then use 
    the said method in the test method using
    the ‘dataProvider‘ attribute in the @Test annotation.CUCUMBER/JUNIT:1.Scenario outline
	2.Excel file with the help ofApachePOI3.JSON or CSV file forAPI testing
	4.Data which comes fromDatabase and stores in collections
	5. @ParameterizedTest-->If you use JUnit-5ExamplesforParameterizedTest:

	@ParameterizedTest
    @ValueSource(ints =1,2,3,4)==>
    it can be ints/strings/booleans/chars(those are keywords)publicvoidvalidateRegionNameTest1(int id)
     xxxxx
    

    @ParameterizedTest
    @CsvSource("1, Europe","2, Americas","3, Asia","4, Middle East and Africa")publicvoidvalidateRegionNameTest2(int id,String name) 
    xxxx
    

    @ParameterizedTest
    @CsvFileSource(resources ="/regions.csv")

    @ParameterizedTest(name ="index => a=0, b=1, sum=2")
    @MethodSource("sumProvider")
  
    @ParameterizedTest(name ="index => pet=''0''")
    @EnumSource(value =Pet.class, names ="CAT")

    @ParameterizedTest(name ="index => a=0, b=1, sum=2")
    @ArgumentsSource(CustomArgumentProvider.class)

Ejemplo 3: pruebas basadas en datos

Whenever a functionality or a module in an app
requires testing with multiple sets ofdata(Parametrization),Multiple inputs then we need to perform data driven testing and
automation.These scenarios are one of the things That must be automated.I would do it by seperating Test data from code and stored into external
sources like
CucumberExamples table,Excel files,CSV files,Database.Data driven testing has lots of benefits like
More organized,Data centralized, and so on

Puedes respaldar nuestro análisis fijando un comentario o dejando una valoración te damos la bienvenida.

¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *