-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb4bae9
commit 4583213
Showing
32 changed files
with
727 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/es/us/isa/restest/examples/Ex10_Iterative_Generation_Execution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package es.us.isa.restest.examples; | ||
|
||
import es.us.isa.restest.runners.RESTestIterativeRunner; | ||
import es.us.isa.restest.util.PropertyManager; | ||
import es.us.isa.restest.util.RESTestException; | ||
|
||
import java.util.logging.Logger; | ||
|
||
/** | ||
* This example shows how to generate test cases, execute them, and generate an Allure report iteratively using RESTestIterativeRunner. | ||
* This can be used to generate and run test cases in small batches, adding a delay among iterations, to prevent API quota violations. | ||
* Also, this is helpful for generating and executing test cases for long periods of time, or even indefinitely until de process is stopped. | ||
* | ||
* For opening Allure reports in a local browser check cross-origin restrictions: https://stackoverflow.com/questions/51081754/cross-origin-request-blocked-when-loading-local-file | ||
* | ||
* The resources for this example are located at src/main/resources/Examples/Ex10_Iterative_Generation_Execution. | ||
* | ||
*/ | ||
public class Ex10_Iterative_Generation_Execution { | ||
|
||
public static final String PROPERTY_FILE_PATH = "src/main/resources/Examples/Ex10_Iterative_Generation_Execution/user_config.properties"; // Path to user properties file with configuration options | ||
|
||
public static final Logger logger = Logger.getLogger(Ex10_Iterative_Generation_Execution.class.getName()); | ||
|
||
public static void main(String[] args) throws RESTestException { | ||
|
||
// Load properties | ||
RESTestIterativeRunner runner = new RESTestIterativeRunner(PROPERTY_FILE_PATH); | ||
|
||
// Run workflow | ||
runner.run(); | ||
|
||
if (logger.isLoggable(java.util.logging.Level.INFO)) { | ||
String message1 = String.format("%d test cases generated and written to %s", runner.getNumberOfTestCases(), runner.getTargetDirJava()); | ||
String message2 = String.format("Allure report available at %s", runner.getAllureReportsPath()); | ||
String message3 = String.format("CSV stats available at %s/%s", PropertyManager.readProperty("data.tests.dir"), runner.getExperimentName()); | ||
String message4 = String.format("Coverage report available at %s/%s", PropertyManager.readProperty("data.coverage.dir"), runner.getExperimentName()); | ||
logger.info(message1); | ||
logger.info(message2); | ||
logger.info(message3); | ||
logger.info(message4); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/es/us/isa/restest/examples/Ex4_ARTestGeneration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package es.us.isa.restest.examples; | ||
|
||
import es.us.isa.restest.generators.ARTestCaseGenerator; | ||
import es.us.isa.restest.runners.RESTestLoader; | ||
import es.us.isa.restest.testcases.TestCase; | ||
import es.us.isa.restest.util.RESTestException; | ||
import es.us.isa.restest.writers.restassured.RESTAssuredWriter; | ||
|
||
import java.util.Collection; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import static es.us.isa.restest.util.FileManager.createDir; | ||
|
||
/** | ||
* This example shows how to generate a set of test cases using SemanticGenerator and write them to a file using the RESTAssured writer. | ||
* These types of tests are based on modifying a generated test so that it is entirely different from the previous one. | ||
* | ||
* The resources for this example are located at src/main/resources/Examples/Ex4_ARTestGeneration. | ||
* | ||
* **/ | ||
|
||
public class Ex4_ARTestGeneration { | ||
|
||
// Need to create the file src\test\resources\auth\OMDb\apikeys.json | ||
public static final String PROPERTY_FILE_PATH = "src/main/resources/Examples/Ex4_ARTestGeneration/omdb.properties"; // Path to user properties file with configuration options | ||
|
||
public static final Logger logger = Logger.getLogger(Ex4_ARTestGeneration.class.getName()); | ||
|
||
public static void main(String[] args) throws RESTestException { | ||
// Load properties | ||
RESTestLoader loader = new RESTestLoader(PROPERTY_FILE_PATH); | ||
|
||
// Create test case generator | ||
ARTestCaseGenerator generator = (ARTestCaseGenerator) loader.createGenerator(); | ||
Collection<TestCase> testCases = generator.generate(); | ||
|
||
// Create target directory for test cases if it does not exist | ||
createDir(loader.getTargetDirJava()); | ||
|
||
// Write (RestAssured) test cases | ||
RESTAssuredWriter writer = (RESTAssuredWriter) loader.createWriter(); | ||
writer.write(testCases); | ||
|
||
if (logger.isLoggable(Level.INFO)) { | ||
String message = String.format("%d test cases generated and written to %s", testCases.size(), loader.getTargetDirJava()); | ||
logger.info(message); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.