GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Convenience System property setting on SystemPropertiesRestoreRule? · Issue #293 · randomizedtesting/randomizedtesting

Convenience System property setting on SystemPropertiesRestoreRule? #293

New issue
Copy link
New issue
Copy link
Open
Open
Convenience System property setting on SystemPropertiesRestoreRule?#293
Copy link

Description

@dsmiley
dsmiley
opened on Nov 13, 2020
Issue body actions

SystemPropertiesRestoreRule is pretty nice. It'd be even nicer if I could conveniently set particular system properties at the site of the rule definition, to make it clear why the rule is there in the first place. This would work by adding a convenient (String key, String value) constructor, and another (Map<String, String> properties) when there is more than one. My proposal here is inspired by https://gist.github.com/mike10004/7f6865b46c23005e9496a53589194788 which I found with some googling.

Of course this isn't necessary. I can define this rule, and then somewhere in some @Before or wherever, I can call System.setProperty(name, value. But my proposal keeps these linked together. One might want to define System.setProperty as a "forbidden API", in tests, and instead rely purely on your JUnit Rule to manipulate them, which communicates to readers that it's important to clean up after test execution.

Activity

  1. dweiss commented on Nov 13, 2020

    @dweiss
    dweiss
    on Nov 13, 2020
    Contributor
    More actions

    Wouldn't a rule-chain with a separate rule (the "setter" rule) underneath serve the same purpose? I understand the notation brevity convenience though - if you care to make a patch, go ahead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.