cucumber.api.java.Before Java Examples
The following examples show how to use
cucumber.api.java.Before.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicHttpHooks.java From pandaria with MIT License | 6 votes |
@Before("@faker") public void faker() { server.server() .post(and( by(uri("/faker/users")), exist(jsonPath("$.name")), not(startsWith(jsonPath("$.name"), "#{")), exist(jsonPath("$.city")), not(startsWith(jsonPath("$.city"), "#{")) )) .response("success"); server.server() .post(and( by(uri("/faker/users/escape")), exist(jsonPath("$.name")), not(startsWith(jsonPath("$.name"), "#{")), exist(jsonPath("$.city")), eq(jsonPath("$.city"), "#{Address.city}") )) .response("success"); server.start(); }
Example #2
Source File: BasicHttpHooks.java From pandaria with MIT License | 6 votes |
@Before("@file_upload") public void fileUpload() { server.server() .post(and( by(uri("/files")), contain(header("Content-Type"), "multipart/form-data") )) .response(text("uploaded")); server.server() .post(and( by(uri("/form")), exist(form("name")), exist(form("data")), exist(form("user")), contain(header("Content-Type"), "multipart/form-data") )) .response(text("uploaded")); server.start(); }
Example #3
Source File: CassandraStepdefs.java From james-project with Apache License 2.0 | 6 votes |
@Before public void init() throws Exception { cassandraServer.start(); temporaryFolder.create(); elasticSearch.start(); mainStepdefs.messageIdFactory = new CassandraMessageId.Factory(); Configuration configuration = Configuration.builder() .workingDirectory(temporaryFolder.newFolder()) .configurationFromClasspath() .build(); mainStepdefs.jmapServer = CassandraJamesServerMain.createServer(configuration) .overrideWith(new TestJMAPServerModule()) .overrideWith(new TestDockerESMetricReporterModule(elasticSearch.getDockerEs().getHttpHost())) .overrideWith(elasticSearch.getModule()) .overrideWith(cassandraServer.getModule()) .overrideWith(binder -> binder.bind(TextExtractor.class).to(DefaultTextExtractor.class)) .overrideWith((binder) -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class)) .overrideWith(binder -> Multibinder.newSetBinder(binder, CleanupTasksPerformer.CleanupTask.class).addBinding().to(CassandraTruncateTableTask.class)) .overrideWith((binder -> binder.bind(CleanupTasksPerformer.class).asEagerSingleton())); mainStepdefs.awaitMethod = () -> elasticSearch.getDockerEs().flushIndices(); mainStepdefs.init(); }
Example #4
Source File: BasicHttpHooks.java From pandaria with MIT License | 6 votes |
@Before("@variables or @code") public void mockForVariableTests() { server.server() .get(by(uri("/not_important"))) .response(json(of( "name", "panda", "age", 18, "iq", 80.0 ))); server.server() .get(by(uri("/simple_response"))) .response(text("SIMPLE_RESPONSE")); server.server() .post(and( by(uri("/users")), eq(jsonPath("$.name"), "someone"))) .response(status(201)) .response(json(of("user", "someone_created"))); server.start(); }
Example #5
Source File: MdpSimulatorHooks.java From java-cme-mdp3-handler with GNU Lesser General Public License v3.0 | 5 votes |
@Before() public void beforeScenario() throws IOException { if (!afterAllAdded) { //Runtime.getRuntime().addShutdownHook(new Thread(DefaultScheduledServiceHolder::shutdown)); afterAllAdded = true; } }
Example #6
Source File: GraphqlHooks.java From pandaria with MIT License | 5 votes |
@Before("@graphql") public void outline() { server.server() .post(and( by(uri("/graphql")), exist(jsonPath("$.query")), exist(jsonPath("$.variables")) )) .response(status(200)) .response(json(of("data", of("book", book())))); server.start(); }
Example #7
Source File: BasicHttpHooks.java From pandaria with MIT License | 5 votes |
@Before("@http_global_headers") public void globalHttpHeaders() { server.server() .get(and( by(uri("/global_header")), eq(header("Authorization"), "Bear Token"), eq(header("global"), "globalHeader"), eq(header("will_be_overrided"), "overrided") )) .response(text("global header added")); server.start(); }
Example #8
Source File: SearchSteps.java From tech-gallery with Apache License 2.0 | 5 votes |
@Before public void before() { // download chromedriver at https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip // unzip ${user.home}/tools/chromedriver System.setProperty("webdriver.chrome.driver", System.getProperty("user.home") + "/tools/chromedriver"); driver = new ChromeDriver(); driver.navigate().to("https://tech-gallery-sandbox.appspot.com"); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS ); driver.manage().window().maximize(); }
Example #9
Source File: CukesCoreHooks.java From cukes with Apache License 2.0 | 5 votes |
@Before(order = 500) public void beforeScenario() { if (cucumberFacade.firstScenario()) { cucumberFacade.beforeAllTests(); } cucumberFacade.beforeScenario(); }
Example #10
Source File: CukesLoadRunnerHooks.java From cukes with Apache License 2.0 | 5 votes |
@Before public void beforeLoadRunnerScenario() { boolean filterEnabled = world.getBoolean(CukesOptions.LOADRUNNER_FILTER_BLOCKS_REQUESTS); if (filterEnabled) { requestFacade.initNewSpecification(); } }
Example #11
Source File: StepDefs.java From coffee-testing with Apache License 2.0 | 5 votes |
@Before public void setUp() { testObject = new OrderValidator(); testObject.coffeeShop = mock(CoffeeShop.class); context = mock(ConstraintValidatorContext.class); List<Origin> origins = TestData.validOrigins(); Set<CoffeeType> coffeeTypes = TestData.validCoffeeTypes(); when(testObject.coffeeShop.getCoffeeTypes()).thenReturn(coffeeTypes); when(testObject.coffeeShop.getOrigin(anyString())).then(invocation -> origins.stream() .filter(o -> o.getName().equals(invocation.<String>getArgument(0))) .findAny() .orElse(null)); }
Example #12
Source File: CassandraStepdefs.java From james-project with Apache License 2.0 | 5 votes |
@Before public void setup() { cassandra = CassandraCluster.create( CassandraModule.aggregateModules(CassandraRRTModule.MODULE, CassandraSchemaVersionModule.MODULE), cassandraServer.getHost()); mainStepdefs.setUp(Throwing.supplier(this::getRecipientRewriteTable).sneakyThrow()); }
Example #13
Source File: BasicHttpHooks.java From pandaria with MIT License | 5 votes |
@Before("@outline") public void outline() { server.server() .post(and( by(uri("/users")) )) .response(template("${req.content}")); server.start(); }
Example #14
Source File: BasicHttpHooks.java From pandaria with MIT License | 5 votes |
@Before("@wait_until") public void sequence() { server.server() .get(by(uri("/sequence"))) .response(seq("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")); server.start(); }
Example #15
Source File: StepDefinitions.java From CleanGUITestArchitecture with MIT License | 5 votes |
@Before public void setUp() throws Exception { mInstrumentationContext = InstrumentationRegistry.getContext(); mAppContext = InstrumentationRegistry.getTargetContext(); registerIdlingResources(); mActivity = mActivityRule.launchActivity(new Intent()); // Start Activity before each test scenario assertNotNull(mActivity); turnOnScreenOfTestDevice(); }
Example #16
Source File: MariaDBHook.java From pandaria with MIT License | 5 votes |
@Before("@multi_db") public void start() throws ManagedProcessException { foo = foo(); bar = bar(); foo.start(); bar.start(); foo.getDB().createDB("pandaria"); bar.getDB().createDB("pandaria"); }
Example #17
Source File: NotificationManagerStepDefs.java From play-with-hexagonal-architecture with Do What The F*ck You Want To Public License | 5 votes |
@Before public void setUp() throws Exception { mockNotificationServiceOne = new MockEventNotificationServiceOne(); mockNotificationServiceTwo = new MockEventNotificationServiceTwo(); mockInMemoryUserEventSettings = new MockInMemoryNotificationSetting(); mockInMemoryUserServiceConfigurationSettings = new MockInMemoryServiceConfiguration(); notificationManagerService = new NotificationCenterServiceImpl( Arrays.asList(mockNotificationServiceOne, mockNotificationServiceTwo), mockInMemoryUserEventSettings, mockInMemoryUserServiceConfigurationSettings); }
Example #18
Source File: RegistrationAndStoringSteps.java From ddd-wro-warehouse with MIT License | 5 votes |
@Before public void setUp() throws Exception { object = ProductStockBuilder.forRefNo("900300") .locationsPicker(l("900300", new Location("A-32-3"))) .events(events) .build(); }
Example #19
Source File: MemoryStepdefs.java From james-project with Apache License 2.0 | 5 votes |
@Before public void init() throws Exception { temporaryFolder.create(); Configuration configuration = Configuration.builder() .workingDirectory(temporaryFolder.newFolder()) .configurationFromClasspath() .build(); mainStepdefs.messageIdFactory = new InMemoryMessageId.Factory(); mainStepdefs.jmapServer = MemoryJamesServerMain.createServer(configuration) .overrideWith(new TestJMAPServerModule(), (binder) -> binder.bind(MessageId.Factory.class).toInstance(mainStepdefs.messageIdFactory)); mainStepdefs.init(); }
Example #20
Source File: RedisHooks.java From redisq with MIT License | 5 votes |
@Before @SuppressWarnings("unchecked") public void setupGlobal() { jedisConnectionFactory.setDatabase(2); redisTemplate.execute((RedisCallback<Object>) connection -> { connection.flushDb(); return null; }); }
Example #21
Source File: DubboDemoStepdefs.java From servicecomb-pack with Apache License 2.0 | 5 votes |
@Before public void cleanUp() { LOG.info("Cleaning up services"); given() .when() .delete(System.getProperty(ALPHA_REST_ADDRESS) + "/saga/events") .then() .statusCode(is(200)); }
Example #22
Source File: InitialSetupHooks.java From akita with Apache License 2.0 | 5 votes |
/** * Создает настойки прокси для запуска драйвера */ @Before(order = 1) public void setDriverProxy() { if (!Strings.isNullOrEmpty(System.getProperty("proxy"))) { Proxy proxy = new Proxy().setHttpProxy(System.getProperty("proxy")); setProxy(proxy); log.info("Проставлена прокси: " + proxy); } }
Example #23
Source File: InitialSetupHooks.java From akita with Apache License 2.0 | 5 votes |
/** * Уведомление о месте запуска тестов * * @throws Exception */ @Before(order = 20) public static void setEnvironmentToTest() throws Exception { if (!Strings.isNullOrEmpty(System.getProperty(REMOTE_URL))) { log.info("Тесты запущены на удаленной машине: " + System.getProperty(REMOTE_URL)); } else log.info("Тесты будут запущены локально"); }
Example #24
Source File: StepEventHandling.java From IridiumApplicationTesting with MIT License | 5 votes |
/** * If any scenario failed, and Iridium is not set to continue after a scenario failure, * we skip any additional steps. This prevents a situation where the test script continues * to run after some earlier failure, which doesn't make sense in end to end tests. */ @Before public void setup() { final String endAfterFirstError = systemPropertyUtils.getProperty(Constants.FAIL_ALL_AFTER_FIRST_SCENARIO_ERROR); final boolean endAfterFirstErrorBool = StringUtils.isBlank(endAfterFirstError) || Boolean.parseBoolean(endAfterFirstError); if (endAfterFirstErrorBool && State.getFeatureStateForThread().getFailed()) { State.getFeatureStateForThread().setSkipSteps(true); } }
Example #25
Source File: BrowserInteropUtilsImpl.java From IridiumApplicationTesting with MIT License | 5 votes |
/** * https://github.com/detro/ghostdriver/issues/20 * Replace window.alert and window.confirm for PhantomJS */ @Before public void setup() { final WebDriver webDriver = State.getThreadDesiredCapabilityMap().getWebDriverForThread(); final boolean isPhantomJS = browserDetection.isPhantomJS(webDriver); final boolean isOpera = browserDetection.isOpera(webDriver); final boolean isFirefox = browserDetection.isFirefox(webDriver); if (!disableInterop() && (isPhantomJS || isOpera || isFirefox)) { final JavascriptExecutor js = (JavascriptExecutor) webDriver; js.executeScript("window.confirm = function(){return true;}"); js.executeScript("window.alert = function(){}"); } }
Example #26
Source File: PageSteps.java From site-infrastructure-tests with Apache License 2.0 | 5 votes |
@Before public void beforeTest() { logger.info("Test setup..."); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.addArguments("--headless"); // driver = new ChromeDriver(chromeOptions); if (logger.isDebugEnabled()) { logger.debug("Initialising ChromeDriver..."); } driver = new RemoteWebDriver(CucumberFeatureTest.getService().getUrl(), chromeOptions); _jsExecutor = (JavascriptExecutor) driver; logger.info("Test setup complete."); }
Example #27
Source File: JsonSchemaMockHooks.java From pandaria with MIT License | 5 votes |
@Before("@verify_json_schema") public void jsonForJsonSchema() { server.server() .get(by(uri("/products/1"))) .response(json(new ImmutableMap.Builder<>() .put("productId", 1) .put("productName", "A green door") .put("price", 12.50) .put("enabled", true) .put("tags", of("home", "green")) .build())); server.start(); }
Example #28
Source File: SignupActivitySteps.java From CucumberEspressoDemo with MIT License | 4 votes |
@Before("@signup-feature") public void setUp() { activityTestRule.launchActivity(new Intent()); activity = activityTestRule.getActivity(); }
Example #29
Source File: LoginActivitySteps.java From CucumberEspressoDemo with MIT License | 4 votes |
@Before("@login-feature") public void setup() { activityTestRule.launchActivity(new Intent()); activity = activityTestRule.getActivity(); }
Example #30
Source File: InitializeWebDrive.java From SeleniumCucumber with GNU General Public License v3.0 | 4 votes |
@Before(order=2,value={"@chrome"}) public void beforeChrome() throws Exception { setUpDriver(BrowserType.Chrome); oLog.info(BrowserType.Chrome); }