A TestNG like dataprovider runner for JUnit with many additional features

Comments
  • Running test from the command line using maven mvn compile test

    Running test from the command line using maven mvn compile test

    I have notice that i seem to be getting an error:

    INFO] Changes detected - recompiling the module! WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b ild is platform dependent! INFO] Compiling 3 source files to C:\Users\921495\IdeaProjects\HMW POC\target\c asses INFO] ------------------------------------------------------------- ERROR] COMPILATION ERROR : INFO] ------------------------------------------------------------- ERROR] /C:/Users/921495/IdeaProjects/HMW POC/src/main/java/com/dataprovider/Dat Providers.java:[3,43] package com.tngtech.java.junit.dataprovider does not exis

    ERROR] /C:/Users/921495/IdeaProjects/HMW POC/src/main/java/com/dataprovider/Dat Providers.java:[11,6] cannot find symbol symbol: class DataProvider location: class com.dataprovider.DataProviders INFO] 2 errors INFO] ------------------------------------------------------------- INFO] ------------------------------------------------------------------------ INFO] BUILD FAILURE INFO] ------------------------------------------------------------------------ INFO] Total time: 2.370 s INFO] Finished at: 2015-08-12T11:38:59+01:00 INFO] Final Memory: 18M/221M INFO] ------------------------------------------------------------------------ ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3. :compile (default-compile) on project my-project-halo: Compilation failure: Com ilation failure: ERROR] /C:/Users/921495/IdeaProjects/HMW POC/src/main/java/com/dataprovider/Dat Providers.java:[3,43] package com.tngtech.java.junit.dataprovider does not exis

    ERROR] /C:/Users/921495/IdeaProjects/HMW POC/src/main/java/com/dataprovider/Dat Providers.java:[11,6] cannot find symbol ERROR] symbol: class DataProvider ERROR] location: class com.dataprovider.DataProviders ERROR] -> [Help 1] ERROR] ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit h. ERROR] Re-run Maven using the -X switch to enable full debug logging. ERROR] ERROR] For more information about the errors and possible solutions, please rea the following articles: ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc ption

    Does mvn support the data provider?

    type: question resolution: fixed 
    opened by Sand5 29
  • Support for JUnit 5

    Support for JUnit 5

    The new JUnit 5 will no longer be based on Runners but on Extensions. Should this become an incompatible new major version or will the support be added by turning JUnit 4 and 5 into optional dependencies?

    type: enhancement resolution: fixed component: junit-jupiter component: junit-jupiter-params 
    opened by aburmeis 23
  • Since multiple @RunWith impossible, a static way to initialize the Runner is needed

    Since multiple @RunWith impossible, a static way to initialize the Runner is needed

    Hello

    I'm using @RunWith(Arquillian.class) and I'd like to @DataProvide my tests there too.

    Since there is no way to say @RunWith twice, how can I use @DataProvider in my Arquillian test class ?

    Is there a way to statically initialize or do whatever mojo is needed to mimic the @RunWith(DataProviderRunner.class) ?

    @Before public void init() { DataProviderRunner.doTheMagic(). }

    type: question 
    opened by sxilderik 21
  • Provide fixed data sets directly in annotation

    Provide fixed data sets directly in annotation

    The junitparams JUnit runner provides a way to define simple fixed data sets directly in the @Parameters annotation:

    @Parameters({ 
                "17, false", 
                "22, true" })
    public void personIsAdult(int age, boolean valid) throws Exception {
        assertThat(new Person(age).isAdult(), is(valid));
    }
    

    This is very useful for simple, fixed data sets as it does not require in these cases to define an additional method. It would be great if the junit-dataprovider would also supports this feature!

    type: enhancement resolution: fixed 
    opened by janschaefer 20
  • Custom parameter format

    Custom parameter format

    I don't know, if this is already possible, and I just don't know about it, but I find myself often writing wrapper objects, simply providing a reasonable toString for the test parameter (e.g. the input is a Class<?> but I don't want class some.pkg.Foo in the output, but would rather have the simple class name).

    Is there any elegant solution for this case? I know I can control the format of the method name, but the parameter always seems to be presented as toString?

    type: enhancement resolution: fixed component: junit4 component: junit-jupiter 
    opened by codecholeric 16
  • Better JUnit-DataProvider support for IntelliJ Idea

    Better JUnit-DataProvider support for IntelliJ Idea

    Problem IntelliJ Idea is not able to run/debug individual (instances) of parametrized test methods, nor is it possible to directly jump to the definition of the test method by clicking in the JUnit window.

    Analysis This is a problem of Idea as the internal implementation is tightly bound the the default parametrized test runner of JUnit.

    Proposal May be there is a way to define an API / interface together with JUnit which then can be used by Idea to get exact information about parametrized tests independent of the used approach and/or TestRunner. The other way to fix it: Provide a patch for Idea which treats the DataProviderRunner in the same way like the JUnit runner and hope it finds it way into a future release of Idea.

    I know this very unspecific to be a direct JUnit-DataProvider feature request, but the bad integration in Idea is annoying and I'm really interested in getting it fixed at same day.

    type: enhancement resolution: wontfix component: external 
    opened by RiccardoBoettcher 15
  • Dataprovider caches results even for dynamically created data / results (e.g. using test method as parameter)

    Dataprovider caches results even for dynamically created data / results (e.g. using test method as parameter)

    Hello , would you help to check the issue. I write a sample in https://github.com/weiro-9-w7/junit-data-provider when you DataProviderExternelFileTest testcase, FrameworkMethod get annotation is the other method annotation.

    @RunWith(DataProviderRunner.class) public class DataProviderExternelFileTest {

    @Test
    @UseDataProvider(value = "loadFromExternalFile", location = LoadFromExternalFile.class)
    @ExternalFile(format = ExternalFile.Format.JSON, value = "persons.json", clazz=Person.class, isArray=true)
    public void should_return_array_when_is_array_is_true(List<Person> person) {
        // Expect:
        assertEquals(person.get(0).getName(), "zhangsan");
        assertEquals(person.get(0).getAge(), 18);
    }
    
    @Test
    @UseDataProvider(value = "loadFromExternalFile", location = LoadFromExternalFile.class)
    @ExternalFile(format = ExternalFile.Format.JSON, value = "person.json", clazz=Person.class)
    public void should_return_object_when_is_array_is_false(Person person) {
        // Expect:
        assertEquals(person.getName(), "zhangsan");
        assertEquals(person.getAge(), 18);
    }
    

    }

    public class LoadFromExternalFile { @DataProvider public static Object[][] loadFromExternalFile(FrameworkMethod testMethod) throws IOException { ExternalFile externalFile = testMethod.getAnnotation(ExternalFile.class); String testDataFile = externalFile.value(); File file = new File(LoadFromExternalFile.class.getResource("/").getPath() + testDataFile); String content = FileUtils.readFileToString(file, "utf8"); if(externalFile.isArray()){ return new Object[][]{{JSON.parseArray(content, externalFile.clazz())}}; }else{ return new Object[][]{{JSON.parseObject(content, externalFile.clazz())}}; } } }

    when you run should_return_array_when_is_array_is_true method, but ExternalFile externalFile = testMethod.getAnnotation(ExternalFile.class); externalFile is should_return_object_when_is_array_is_false

    type: enhancement resolution: fixed component: junit4 component: junit-jupiter component: junit-jupiter-params 
    opened by weiro-9-w7 14
  • Combination of string based @DataProvider and @UseDataProvider

    Combination of string based @DataProvider and @UseDataProvider

    Hi there,

    in our security tests, there are several methods that look like this:

        @Test
        @DataProvider({
                ENABLED_QUOTATION_AND_STARTED_ENDED_PUBLISHED_RFQ,
                ENABLED_QUOTATION_AND_NOT_STARTED_NOT_ENDED_PUBLISHED_RFQ,
                ENABLED_QUOTATION_AND_STARTED_NOT_ENDED_PUBLISHED_RFQ,
                DISABLED_QUOTATION_AND_STARTED_NOT_ENDED_PUBLISHED_RFQ,
                DISABLED_QUOTATION_AND_NOT_STARTED_NOT_ENDED_PUBLISHED_RFQ,
                ENABLED_QUOTATION_AND_STARTED_NOT_ENDED_NOT_PUBLISHED_RFQ
        })
        public void validate_access_for_buyer_for_not_related_rfq(boolean isQuotationEnabled, boolean hasRfqStarted, boolean hasRfqEnded,
                boolean isPublished)
                throws Exception {
            (...)
        }
    

    As string arrays are not supported in annotations, it would be great if there would be the possibility to extract string based dataproviders into a separate method. Otherwise, a custom string processing is required.

    Regards, Niko

    type: enhancement resolution: fixed 
    opened by nikowitt 13
  • FrameworkMethod didn't get the right test

    FrameworkMethod didn't get the right test

    • ( ) Bug report. version: junit4-dataprovider 2.6

    my test class likes this image

    my dataprovider likes this image

    when I run the getProduct case, the method is not getProduct, why?

    opened by laaron2008 12
  • Can Gradle run these tests in parallel?

    Can Gradle run these tests in parallel?

    Gradle cannot run JUnit @Parameterized tests in parallel, but TestNG has a parallel Boolean parameter on the @DataProvider annotation. Can Gradle run the junit-dataprovider tests in parallel?

    type: question status: discussion component: external 
    opened by thejohnfreeman 12
  • Show test parameter names in test name?

    Show test parameter names in test name?

    At least with java 8 it could be possible to display the name of the test method parameters (instead of the index) in the test name. For example display testDevision[dividend:10, divisor: 2, quotient:5] instead of testDevision[0:10, 1: 2, 2:5] as test name.

    type: enhancement resolution: fixed component: core 
    opened by PascalSchumacher 12
  • rerunFailingTestsCount + @DataProvider = failed tests are recognized as flakes

    rerunFailingTestsCount + @DataProvider = failed tests are recognized as flakes

    Overview

    Bug report.

    The combination of rerunFailingTestsCount=3 of the maven surefire plugin with the TestNG junit dataprovider did not fail the test, instead it's just marked as flaky, even the count is reached.

    There was an issue on the surefire plugin which discusses exactly this problem:
    SUREFIRE-1228 (contains a test case as well).

    But it seems to me, that the dataprovider is not fully working together with the surefire rerunFailingTestsCount option.

    ACTUAL: The maven log ends just flaky (full report in attachment) [WARNING] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Flakes: 1

    EXPECTED: The test goes into failure, because even after rerun 3 times the test is not passed.

    Versions tested maven-surefire-plugin is latest 3.0.0-M7 com.tngtech.java:junit-dataprovider:1.13.1

    I tried even your latest version com.tngtech.junit.dataprovider:junit4-dataprovider:2.9, but still the same maven result: just marked as flaky, but not goes to failure.

    Deliverables

    maven-log-just-flaky.txt

    component: junit4 
    opened by camproto 8
Releases(v2.10)
  • v2.10(Dec 26, 2022)

    • Fixes JUnit's internal changes throwing an NoClassDefFoundError by using DefaultExecutableInvoker instead of ExecutableInvoker (now an interface` (#136, #137)

    Maven Central: v2.10

    Source code(tar.gz)
    Source code(zip)
  • v2.9(Mar 13, 2022)

  • v2.8(Jan 31, 2021)

    • Support lists of non-iterable parameterized type (#132)

    Only relevant for developers

    • Fix and cleanup duplicates, spotbugs and fail build on new ones? (#122)
    • Fix coveralls report (#125)
    • Migrate build scripts to new Kotlin DSL (#123)
    • GitHub Actions checkout v2 (#124)
    • Upgrade to maven-publish plugin as Gradle broke signing with 5.1.1 (#119)

    Maven Central: v2.8

    Source code(tar.gz)
    Source code(zip)
  • v2.7(Nov 6, 2020)

  • v2.6(Jul 6, 2019)

  • v2.5(Jul 6, 2019)

    • Compatibilty with junit-jupiter-engine == 5.4.* (#118)

    Note: This version is only compatible with JUnit Jupiter 5.4.* because of internal refactorings, see also https://github.com/TNG/junit-dataprovider/wiki/Version-compatibility.

    Maven Central: v2.5

    Source code(tar.gz)
    Source code(zip)
  • v2.4(Sep 26, 2018)

  • v2.3(Apr 2, 2018)

  • v2.2(Jan 29, 2018)

  • v2.1(Jan 14, 2018)

    • DataProviders#crossProduct Iterable support component: core resolution: fixed type: enhancement (#103)
    • Fix dataprovider discovery error if test case is in base classes and dataprovider in child (executed test class) (#104)
      • This has worked until v1.11.0 but an overlooked regression broke this in v1.12.0

    Maven Central: v2.1

    Source code(tar.gz)
    Source code(zip)
  • v2.0(Nov 11, 2017)

    • Refactor out core/ to be independent from any JUnit framework and dataprovider annotations
    • Introduce completely new / rewritten dataprovider resolvers
    • Support for JUnit 5 with two differnent approaches (@TestTemplate and @ParameterizedTest) (#75)
    • Enable JUnit5 dataprovider to handle additional "ParameterResolver" parameters (#102)
    • Show test parameter names in tests display name (JUnit Jupiter only) (#90)

    Maven Central: v2.0 Migration guides: here

    Source code(tar.gz)
    Source code(zip)
  • v2.0-SNAPSHOT_2(Nov 5, 2017)

    • Enable JUnit5 dataprovider to handle additional "ParameterResolver" parameters (#102)
    • Show test parameter names in tests display name (JUnit Jupiter only) (#90)
    Source code(tar.gz)
    Source code(zip)
  • v2.0-SNAPSHOT(Nov 5, 2017)

    • Refactor out core/ to be independent from any JUnit framework and dataprovider annotations
    • Introduce completely new / rewritten dataprovider resolvers
    • Support for JUnit 5 with two differnent approaches (@TestTemplate and @ParameterizedTest) (#75)
    Source code(tar.gz)
    Source code(zip)
  • v1.13.1(Oct 4, 2017)

  • v1.13.0(Sep 25, 2017)

    • Add support of wildcard types for List dataproviders (#86)
    • Prepared structure to extract core/ to reuse it with junit-jupiter (move source to junit4/ subdirectory)

    Maven Central: v1.13.0

    Source code(tar.gz)
    Source code(zip)
  • v1.12.0(Oct 23, 2016)

    • use Gradle OSGi plugin to create MANIFEST.MF (#56)
    • Ability to provide custom resolvers to find a proper dataprovider method (#70)
    • relax List dataprovider outer and inner types (#78)

    Maven Central: v1.12.0

    Source code(tar.gz)
    Source code(zip)
  • v1.11.0(Apr 11, 2016)

    • Improved extensibility of DataProviderRunner to customize all helpers, e.g. StringConverter (#52)
    • Fixed failing tests if using \0 character in test data (#73)
    • Allow additional convention for @DataProvider method name (#76)

    Maven Central: v1.11.0

    Source code(tar.gz)
    Source code(zip)
  • v1.10.4(Mar 8, 2016)

    • !!!Breaking change!!! removing @BeforeClass support as it runs all @BeforeClass methods while starting up JUnit even if no test from this method will be executed (#49, #64)
      • The breaking change affects you if you use the results of a @BeforeClass method within a dataprovider method.
    • fixed NPE if first argument is null having empty second varargs argument
    • added convention for default dataprovider name to avoid explicit name in @UseDataProvider (#54)

    Maven Central: v1.10.4

    Source code(tar.gz)
    Source code(zip)
  • v1.10.3(Feb 18, 2016)

    • Added option to @DataProvider to ignore case for Enums (#58)
    • fixes NullPointerException when toString() of parameter returns null (#66)
    • Supports Object[] and List<Object> for single parameter test methods (#67)
    • Added crossproduct of data providers (#69)

    Maven Central: [v1.10.3](http://search.maven.org/#artifactdetails|com.tngtech.java|junit-dataprovider|1.10.3|jar

    Source code(tar.gz)
    Source code(zip)
  • v1.10.2(Oct 25, 2015)

    • @DataProvider.splitBy() should be only invoked when it is required accepted enhancement (#61)
    • fixed Eclipse behavior when toString() implementation contains a new line (#59)
    • Provide constants for @DataProvider values and "null" string (#55)

    Maven Central: [v1.10.2](http://search.maven.org/#artifactdetails|com.tngtech.java|junit-dataprovider|1.10.2|jar

    Source code(tar.gz)
    Source code(zip)
  • v1.10.1(Aug 11, 2015)

  • v1.10.0(Jul 14, 2015)

  • v1.9.4(May 31, 2015)

  • v1.9.3(Feb 17, 2015)

    • fixed filtering for newlines in test method description (#41)
    • avoid newlines in test method description by replacing them with their String counterparts (#42)

    Maven Central: v1.9.3

    Source code(tar.gz)
    Source code(zip)
  • v1.9.2(Feb 17, 2015)

    • added Travis builds for all supported junit-versions (#37)
    • @BeforeClass setup methods are executed before @DataProvider methods (#22)
    • allow widening conversions of primitive types automatically (#39)

    Maven Central: v1.9.2

    Source code(tar.gz)
    Source code(zip)
  • v1.9.1(Feb 17, 2015)

    • fixed exception if dollar ($) is contained in @DataProvider parameters (#34)
    • fixed bug that ClassRules does not work anymore for [JUnit][] > 4.8.2 (#35) (by reverting (#22))

    Maven Central: v1.9.1

    Source code(tar.gz)
    Source code(zip)
  • v1.9.0(Feb 17, 2015)

    !!! Do not use this version as of (#34) and (#35), sorry for the inconvenience !!!

    • improved error messages (#31)
    • added some helpful utility methods (#21)
    • made test name customizable via @DataProvider#format() (#30)
    • executing @BeforeClass before @DataProvider methods (#22)
    • split README.md and use wiki instead (#32)

    Maven Central: ~~v1.9.0~~

    Source code(tar.gz)
    Source code(zip)
  • v1.8.0(Feb 17, 2015)

    • added splitBy, convertNulls and `trimValuesparameter to@DataProvider`` (#24)
    • more fault tolerant filtering instead of explicitly maintain a black or white list (#27)
    • @DataProvider method can now optionally access corresponding FrameworkMethod via parameter (#28)

    Maven Central: v1.8.0

    Source code(tar.gz)
    Source code(zip)
  • v1.7.0(Feb 17, 2015)

    • implemented #20 to use @DataProvider directly providing test data for test method
    • support any type which have a single-argument String constructor for String[] dataprovider (#26)
    • removed some internal technical debts by refactoring (#23 and #25)

    Maven Central: v1.7.0

    Source code(tar.gz)
    Source code(zip)
  • v1.6.0(Feb 17, 2015)

    • fixed bug in fix #16 using IntelliJ (#18) with merge #19)
    • added support for List<List<Object>> besides Object[][] for languages with native List support (#17)

    Maven Central: v1.6.0

    Source code(tar.gz)
    Source code(zip)
Owner
TNG Technology Consulting GmbH
TNG Technology Consulting GmbH is a value-based consulting partnership focused on high end information technology.
TNG Technology Consulting GmbH
A sample repo to help you capture JavaScript exception for automation test in Java-TestNG on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to capture JavaScript exception for automation test in Java-TestNG on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Ma

null 11 Jul 13, 2022
A sample repo to help you use relative locators for automation test in Java-TestNG on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to use relative locators for automation test in Java-TestNG on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven wit

null 11 Jul 13, 2022
A sample repo to help you use CDP console in Java-TestNG automation test on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to use CDP console in Java-TestNG automation test on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Homebrew

null 11 Jul 13, 2022
A sample repo to help you capture performance logs in Java-TestNG using CDP on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to capture performance logs in Java-TestNG using CDP on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Homeb

null 12 Jul 13, 2022
A sample repo to help you intercept network with Java-TestNG on LambdaTest cloud. Run Selenium tests with TestNG on LambdaTest platform.

How to intercept network with Java-TestNG on LambdaTest cloud Environment Setup Global Dependencies Install Maven Or Install Maven with Homebrew (Easi

null 12 Oct 23, 2022
A sample repo to help you set geolocation for automation test in Java-TestNG on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to set geolocation for automation test in Java-TestNG on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Home

null 12 Jul 13, 2022
A sample repo to help you emulate network control using CDP in Java-TestNG automation test on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to emulate network control using CDP in Java-TestNG automation test on LambdaTest Environment Setup Global Dependencies Install Maven Or Install M

null 12 Oct 23, 2022
A sample repo to help you handle basic auth for automation test in Java-TestNG on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to handle basic auth for automation test in Java-TestNG on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Ho

null 11 Jul 13, 2022
A sample repo to help you set device mode using CDP in Java-TestNG automation test on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to set device mode using CDP in Java-TestNG automation test on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven wit

null 11 Jul 13, 2022
A sample repo to help you test in Java-TestNG-Appium for LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

Sample automation test in Java-TestNG-Appium for LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Homebrew (Easier

null 13 Jul 13, 2022
fabric-carpet extension mod which attempts to fix as many vanilla bugs as possible. Feel free to add as many fixes as you want!

Carpet-Fixes Fabric Carpet extension mod which attempts to fix as many vanilla bugs as possible! Feel free to contribute by adding as many fixes as yo

Fx Morin 90 Jan 6, 2023
A simple yet powerful parameterized test runner for Java.

TestParameterInjector Introduction TestParameterInjector is a JUnit4 test runner that runs its test methods for different combinations of field/parame

Google 324 Dec 30, 2022
A BDD-style test runner for Java 8. Inspired by Jasmine, RSpec, and Cucumber.

Spectrum A colorful BDD-style test runner for Java Spectrum is inspired by the behavior-driven testing frameworks Jasmine and RSpec, bringing their ex

Greg Haskins 143 Nov 22, 2022
TestNG testing framework

Documentation available at TestNG's main web site. Release Notes 7.4.0 7.3.0 7.1.0 7.0.0 Need help? Before opening a new issue, did you ask your quest

Cedric Beust 1.8k Jan 5, 2023
BDD framework for automation using Selenium Cucumber and TestNg

Selenium Framework with Cucumber BDD framework for automation using Selenium Cucumber and TestNg The framework has following features Modular Design M

null 3 Jan 20, 2022
An e-commerce automation project of Selenium TestNG using Page Object Model

Selenium-POM-TestNG Prerequisites Install jdk 8 or any LTS version Configure JAVA_HOME and GRADLE_HOME Download Allure 2.17.2 and configure environmen

Asif Shahriar 2 Aug 4, 2022
java接口自动化测试框架:java + testng + httpclient + allure + ...

设计思路、使用方式、待扩展功能等 主要技术栈:java + testng + httpclient + allure + fastjson + jsonpath + ... 设计思路 使用方式 待扩展功能 效果图 自动化测试框架(汇总) 干货分享 从测试小白到高级测试修炼之路,持续更新中:https

持之以恒(韧) 12 Dec 5, 2022
Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.

Testcontainers Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium we

null 6.7k Jan 9, 2023