All Downloads are FREE. Search and download functionalities are using the official Maven repository.

testgeneration_templates.GeneratedLoadTest.tmp Maven / Gradle / Ivy

There is a newer version: 3.1.1
Show newest version
package ${package};

import static com.loadcoder.statics.LogbackLogging.getNewLogDir;
import static com.loadcoder.statics.LogbackLogging.setResultDestination;
import static com.loadcoder.statics.Statics.*;

import com.loadcoder.load.chart.logic.RuntimeChart;
import com.loadcoder.load.scenario.ExecutionBuilder;
import com.loadcoder.load.scenario.Load;
import com.loadcoder.load.scenario.LoadBuilder;
import com.loadcoder.load.scenario.LoadScenarioTyped;
import com.loadcoder.load.scenario.Scenario;
import com.loadcoder.result.Result;
import com.loadcoder.statics.SummaryUtils;

import static org.junit.Assert.assertEquals;
import org.junit.Test;


${importList}

public class GeneratedLoadTest {


	LoadScenarioTyped loadScenario = new LoadScenarioTyped() {

		@Override
		public void loadScenario(ThreadInstance t) {
			t.getScenarioLogic().performScenario();
		}

		@Override
		public ThreadInstance createInstance() {
			/*
			 * The ThreadInstance created here for each thread will be a container for
			 * everything uniquely to each specific thead, and will in this case also hold
			 * separate instances for the load test logic.
			 */
			return new ThreadInstance(this);
		}
	};

	@Test
	public void bestPractiseLoadTestDesign() {

		// Giving the test a unique directory for the result logs
		setResultDestination(getNewLogDir("target", "bestPracticeLoadTest"));

		Load load = new LoadBuilder(loadScenario)
		${loadBuilder}
		.build();

		Result result = new ExecutionBuilder(load)
		${storeAndConsumeResultRuntime}
		.build().execute()
		.andWait().getReportedResultFromResultFile();

		SummaryUtils.printSimpleSummary(result, "Greetings loadtest");

	}

	/**
	 * This test how you can invoke your test logic without having to setup a load
	 * test. These kinds of tests is perfect to execute early in the development
	 * cycle in order to verify that the load test logic still works
	 */
	@Test
	public void testGreetingsLogicAlone() {
		Result result = loadScenario.test();
		SummaryUtils.printSimpleSummary(result, "LoadScenario Test");
		assertEquals(result.getAmountOfFails(), 0);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy