Campoie / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

Global configuration mechanism wanted #84

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In every test case I have to repeat this:

    @BeforeClass
    public static void configureRestAssured() {
        RestAssured.port = Integer.valueOf(System.getProperty("jetty.port"));
    }

Would be much better to enable this configuration directly through some system 
property. I would set it once in pom.xml and RestAssured understand its value 
and configure itself. Makes sense?

Original issue reported on code.google.com by yegor256 on 9 Jul 2011 at 6:03

GoogleCodeExporter commented 9 years ago
The same for baseURI and basePath. They should be configured just once per test 
cycle, not in every test case.

Original comment by yegor256 on 9 Jul 2011 at 6:18

GoogleCodeExporter commented 9 years ago
What I usually do is to define base class that every test inherit from that 
defines the RA properties (port, baseURI etc). But since "port" etc are static 
variables it should be enough to define them once. You may need to configure 
your junit fork mode settings in ant or surefire. Perhaps a system property 
could be a viable option as well though. 

Original comment by johan.ha...@gmail.com on 9 Jul 2011 at 1:18

GoogleCodeExporter commented 9 years ago
Well, one base class for all test cases sounds like a very dirty solution. 
Would be much better to enable global configuration of RestAssured through 
".properties" file, or system variables (the most preferable way). Thanks!

Original comment by yegor256 on 9 Jul 2011 at 5:36

GoogleCodeExporter commented 9 years ago
If you don't like inheritance you could also create a JUnit Rule which defines 
your settings and apply that for each test class.

Original comment by johan.ha...@gmail.com on 15 Jul 2011 at 7:08

GoogleCodeExporter commented 9 years ago
Good suggestion for a workaround, thanks!

Original comment by yegor256 on 15 Jul 2011 at 8:51

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 22 Jan 2014 at 10:01