Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency pl.pragmatists:JUnitParams to v1.1.1 #69

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Oct 28, 2024

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
pl.pragmatists:JUnitParams 1.0.4 -> 1.1.1 age adoption passing confidence

Release Notes

Pragmatists/JUnitParams (pl.pragmatists:JUnitParams)

v1.1.1

Regexp bugfix

New version works well for Instrumented Unit Test for Android 19 and below.

Thanks mattmook and aaalaniz for contribution.

v1.1.0

[Breaking change] Enhance ParametersProvider with FrameworkMethod

ParametersProvider#initialize method was enhanced with new parameter - FrameworkMethod object. It gives access to all information connected with method in testing e.g. annotations.

    public static class MethodNameReader implements ParametersProvider<CustomParameters> {
        private FrameworkMethod frameworkMethod;
    
        @&#8203;Override
        public void initialize(CustomParameters parametersAnnotation, FrameworkMethod frameworkMethod) {
            this.frameworkMethod = frameworkMethod;
        }
    
        @&#8203;Override
        public Object[] getParameters() {
            return new Object[]{frameworkMethod.getName()};
        }
    }

How to migrate? Add new parameter to ParametersProvider#initialize method if you are using any custom parameters provider.

Thanks bohrqiu for contribution.

Possibility to link parameters to test case by @Named annotation

In some cases we can don't want to link parameters to test case by method name or putting everything into the test case annotation. We introduce possibility to define custom name for the connection by using @NamedParameters annotation.

    @&#8203;Test
    @&#8203;Parameters(named = "return 1")
    public void testSingleNamedMethod(int number) {
        assertThat(number).isEqualTo(1);
    }

    @&#8203;NamedParameters("return 1")
    private Integer[] returnNumberOne() {
        return new Integer[] { 1 };
    }

Thanks tobyt42 for idea and contribution.

Speedups

New version is noticeably faster for big as well as small set of parameters.

Thanks for ukcrpb6 for contribution.

v1.0.6

Change default testcase naming template

Due to problems with test results presentation e.g. in Jenkins where test cases
will be not ordered by execution but by naming, default test case naming template was changed to:

{method}({params}) [{index}]

from

[{index}] {params} ({method})

Thanks to ealgell for contribution.

v1.0.5

Deprecated $ method

Utility method $ was deprecated. It was causing too much problems and we decided not to support it any more. If you wish to keep using it, implement it in your own codebase.

Automatic class name to class object conversion
    @&#8203;Test
    @&#8203;Parameters({"java.lang.Object", "java.lang.String"})
    public void passClassAsString(Class<?> clazz) {
        assertThat(clazz).isIn(java.lang.Object.class, java.lang.String.class);
    }

Thanks to adammichalik for contribution

Support custom annotations for parameter conversion

You can create your own annotations for parameter conversion. Just annotate it with @Param and pass it a reference to Converter implementation.

Example:

    @&#8203;Retention(RetentionPolicy.RUNTIME)
    @&#8203;Target(ElementType.PARAMETER)
    @&#8203;Param(converter = FormattedDateConverter.class)
    public @&#8203;interface DateParam {

        String format() default "dd.MM.yyyy";
    }

    public static class FormattedDateConverter implements Converter<DateParam, Date> {

        private String format;

        @&#8203;Override
        public void initialize(DateParam annotation) {
            this.format = annotation.format();
        }

        @&#8203;Override
        public Date convert(Object param) throws ConversionFailedException {
            try {
                return new SimpleDateFormat(format).parse(param.toString());
            } catch (ParseException e) {
                throw new ConversionFailedException("failed");
            }
        }
    }

Usage example:

    @&#8203;Test
    @&#8203;Parameters({"2012-12-01"})
    public void testWithConvertedDate(@&#8203;DateParam Date date) {
        assertThat(...);
    }

Thanks to bbobcik for inspiration

CustomParameters

You can create custom annotations for parameter providers. @FileParameters have been refactored to use this mechanism and should serve as a perfect usage example.

    @&#8203;Retention(RetentionPolicy.RUNTIME)
    @&#8203;Target(ElementType.METHOD)
    @&#8203;CustomParameters(provider = FileParametersProvider.class)
    public @&#8203;interface FileParameters {

        String fileLocation();
    
    }

    public class FileParametersProvider implements ParametersProvider<FileParameters> {

        private String fileLocation;
    
        @&#8203;Override
        public void initialize(FileParameters fileParameters) {
            this.fileLocation = fileParameters.fileLocation();
        }
    
        @&#8203;Override
        public Object[] getParameters() {
            return paramsFromFile(fileLocation);
        }
        
        ...
    }
@​CombinedParameters

Thanks to piekarskim The issue #​1 is fixed.
Using this annotation will result in creating a n-fold cartesian product of parameter values effectively testing each possible combination.
Since an example is worth a thousand words:

Such annotated test method:

    @&#8203;Test
    @&#8203;CombinedParameters({"a,b", "1,2"})
    public void calledWithCartesianProduct(String character, Integer number) {
    ...
    }

Will be called 4 times with parameters:

 a  1 
 a  2 
 b  1 
 b  2 
Bug fixes and improvements

Thanks to the rest of contributors for lots of bug fixes and improvements:


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot force-pushed the renovate/pl.pragmatists-junitparams-1.x branch 9 times, most recently from 0ecdc89 to 14cce04 Compare October 28, 2024 21:40
@renovate renovate bot force-pushed the renovate/pl.pragmatists-junitparams-1.x branch from 14cce04 to 5cd7af5 Compare October 28, 2024 21:40
@kpavlov kpavlov merged commit 0d5d887 into master Oct 28, 2024
2 checks passed
@kpavlov kpavlov deleted the renovate/pl.pragmatists-junitparams-1.x branch October 28, 2024 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant