Best EvoMaster code snippet using org.evomaster.e2etests.spring.examples.adaptivehypermutation.AHypermutationAWHTest.initClass
Source:AHypermutationAWHTest.java
...11import java.util.List;12import static org.junit.jupiter.api.Assertions.*;13/**14 * with same budget, i.e., 20_000 HTTP calls (see {@link #budget})15 * for the example (only include /foos/{x} endpoints see {@link #initClass()}),16 * we tested the performances of default MIO and MIO-WH* based on17 * a capability of covering expected targets(see {@link #countExpectedCoveredTargets(Solution, List)}).18 * There are three prerequisites of the expected targets, i.e.,19 * 1) there must exist 3 foo in DB and 2) specified x must not exist in DB and 3) specified y is "foo"20 * NOTE THAT all of the prerequisites must be satisfied in order to reach the expected targets.21 *22 * Based on the tests, with 3 attempts,23 * 1) default MIO always covers less than 2 out of the 6 expected targets, i.e., 0 (likely) or 1;24 * 2) MIO-WH* is able to cover all of the 6 expected targets.25 * In addition, we also provide a sample test generated by MIO-WH* {@link org.evomaster.e2etests.spring.examples.adaptivehypermutation.EvoMasterAWHSampleTest}26 *27 * Outputs by the tests can be found:28 * 1) target/em-tests/AWH/TestBase org.adaptivehypermuation.BaseTest is the test generated by default MIO29 * 2) target/em-tests/AWH/TestAHW org.adaptivehypermuation.AWHTest is the test generated by MIO-WH*30 * 3) target/em-tests/AWH/statistics.csv records detailed performance in coverage including target, line and branch.31 * 4) target/em-tests/AWH/snapshot.csv records more detailed performance i.e., every 5% of the used budget, throughout search,32 */33public class AHypermutationAWHTest extends AHypermuationTestBase {34 private final static int budget = 20_000;35 private static String statisticsFile = TESTS_OUTPUT_ROOT_FOLDER + "/AWH/statistics.csv";36 private static String snapshotFile = TESTS_OUTPUT_ROOT_FOLDER + "/AWH/snapshot.csv";37 private final static int SEED = 42;38 @Test39 public void testRunMIO() {40 CIUtils.skipIfOnCircleCI();41 CIUtils.skipIfOnGA();42 defaultSeed = SEED;43 List<String> msg = new ArrayList<>();44 assertThrows(Throwable.class, () -> {45 runTestHandlingFlakyAndCompilation(46 "AWH/TestBase",47 "org.adaptivehypermuation.BaseTest",48 budget,49 true,50 (args) -> {51 args.add("--probOfArchiveMutation");52 args.add("0.0");53 args.add("--weightBasedMutationRate");54 args.add("false");55 args.add("--adaptiveGeneSelectionMethod");56 args.add("NONE");57 args.add("--archiveGeneMutation");58 args.add("NONE");59 args.add("--enableTrackEvaluatedIndividual");60 args.add("false");61 args.add("--writeStatistics");62 args.add("true");63 args.add("--statisticsFile");64 args.add(statisticsFile);65 args.add("--appendToStatisticsFile");66 args.add("true");67 args.add("--snapshotInterval");68 args.add("5");69 args.add("--snapshotStatisticsFile");70 args.add(snapshotFile);71 args.add("--statisticsColumnId");72 args.add("awh-example-base");73 Solution<RestIndividual> solution = initAndRun(args);74 int count = countExpectedCoveredTargets(solution, msg);75 assertTrue(count >= 2);76 }, 10);77 }, String.join("\n", msg));78 }79 @Test80 public void testRunMIOAWH() throws Throwable {81 CIUtils.skipIfOnCircleCI();82 CIUtils.skipIfOnGA();83 defaultSeed = SEED;84 runTestHandlingFlakyAndCompilation(85 "AWH/TestAHW",86 "org.adaptivehypermuation.AWHTest",87 budget,88 true,89 (args) -> {90 args.add("--probOfArchiveMutation");91 args.add("0.5");92 args.add("--weightBasedMutationRate");93 args.add("true");94 args.add("--adaptiveGeneSelectionMethod");95 args.add("APPROACH_IMPACT");96 args.add("--archiveGeneMutation");97 args.add("SPECIFIED_WITH_SPECIFIC_TARGETS");98 args.add("--enableTrackEvaluatedIndividual");99 args.add("true");100 args.add("--writeStatistics");101 args.add("true");102 args.add("--statisticsFile");103 args.add(statisticsFile);104 args.add("--appendToStatisticsFile");105 args.add("true");106 args.add("--snapshotInterval");107 args.add("5");108 args.add("--snapshotStatisticsFile");109 args.add(snapshotFile);110 args.add("--statisticsColumnId");111 args.add("awh-example-awh");112 Solution<RestIndividual> solution = initAndRun(args);113 List<String> msg = new ArrayList<>();114 int count = countExpectedCoveredTargets(solution, msg);115 assertEquals(6, count, String.join("\n", msg));116 }, 10);117 }118 @BeforeAll119 public static void initClass() throws Exception {120 SpringTestBase.initClass(new AHypermutationRestController(Arrays.asList("/api/bars/{a}")));121 }122}...
initClass
Using AI Code Generation
1import org.evomaster.client.java.controller.api.dto.SutInfoDto2import org.evomaster.client.java.controller.internal.db.SqlScriptRunner3import org.evomaster.client.java.controller.internal.db.SqlScriptRunnerImpl4import org.evomaster.core.EMConfig5import org.evomaster.core.Main6import org.evomaster.core.output.OutputFormat7import org.evomaster.core.problem.rest.RestIndividual8import org.evomaster.core.problem.rest.service.ResourceCreator9import org.evomaster.core.problem.rest.service.RestResourceCalls10import org.evomaster.core.remote.service.RemoteController11import org.evomaster.core.search.Action12import org.evomaster.core.search.EvaluatedIndividual13import org.evomaster.core.search.Individual14import org.evomaster.core.search.gene.Gene15import org.evomaster.core.search.gene.IntegerGene16import org.evomaster.core.search.gene.StringGene17import org.evomaster.core.search.service.Randomness18import org.evomaster.core.search.service.mutator.StandardMutator19import org.evomaster.e2etests.spring.examples.adaptivehypermutation.AHypermutationAWHTest.Companion.initClass20import org.evomaster.e2etests.spring.examples.adaptivehypermutation.AHypermutationAWHTest.Companion.runTestHandlingFlakyAndCompilation21import org.evomaster.e2etests.spring.examples.adaptivehypermutation.AHypermutationAWHTest.Companion.runTestHandlingFlakyAndCompilationAndArchive22import org.evomaster.e2etests.spring.examples.adaptivehypermutation.AHypermutationAWHTest.Companion.runTestHandlingFlakyAndCompilationAndArchiveAndExport23import org.evomaster.e2etests.spring.examples.adaptivehypermutation.AHypermutationAWHTest.Companion.runTestHandlingFlakyAndCompilationAndExport24import org.evomaster.e2etests.spring.examples.adaptivehypermutation.AHypermutationAWHTest.Companion.runTestHandlingFlakyAndCompilationAndExportAndArchive25import org.evomaster.e2etests.spring.examples.adaptivehypermutation.AHypermutationAWHTest.Companion.runTestHandlingFlakyAndCompilationAndExportAndArchiveAndVerify26import org.evomaster.e2etests.spring.examples.adaptivehypermutation.AHypermutationAWHTest.Companion.runTestHandlingFlakyAndCompilationAndVerify27import org.evomaster.e2etests.spring.examples.adaptivehypermutation
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!