integration-testing

How can I use IConfiguration from my integration tests?

本小妞迷上赌 提交于 2019-12-02 03:34:16
问题 I have an API, and I'm trying to make some integration tests for it with XUnit. Here's my API controller constructor: public class MyController : Controller { readonly IMyRepository _myRepository; public MyController(IMyRepository myRepository) { _myRepository = myRepository; } public async Task<IActionResult> GetUser(Guid userId) { try { return Ok(await _my.GetUser(userId)); } catch (Exception ex) { return StatusCode(500, "An error occurred while handling your request."); } } } My API

Cucumber: Scenario Outline reusing examples table

我与影子孤独终老i 提交于 2019-12-02 02:09:24
I have a few tests like below: Scenario Outline: Add two numebrs Given two numbers <number_1> and <number_2> When I add them Then Result is <number_3> Examples: |number_1|number_2|number_3| |2 |3 |5 | |1 |2 |3 | Scenario Outline: Update two numebrs Given two numbers <number_1> and <number_2> When I update them Then Result is <number_3> Examples: |number_1|number_2|number_3| |2 |3 |5 | |1 |2 |3 | For each test I should add the same table Examples . Is any way to extract this table to use the same one for all tests? The easiest solution that comes to my mind is combining both scenarios,

Writing tests for an Android app that logs into Facebook

五迷三道 提交于 2019-12-02 01:08:54
My Android app uses FacebookSDK for login. It's the first screen, and you can't do anything unless you login. I want to write some Espresso tests to be ran on Greenhouse Continuous integration server. I searched and I found FBSDKTestUsersManager on iOS, but nothing similar on Android. What I plan to do is create a flavor of test and when that flavor is selected instead of a normal Facebook login button, I'd display a button that gets a test access token for the user, then brings them to the homepage of the app. However, I can't do that cause FBSDKTestUsersManager doesn't exist on Android. Any

How to run selenium 3.x with chrome driver through terminal

你。 提交于 2019-12-01 17:51:13
May be it's easy question but I can't find any info about that. I used to run selenium 2.x as that way. I start server: java -jar selenium-server-standalone-2.53.1.jar -Dwebdriver.chrome.driver=chromedriver -browserSideLog -debug -timeout 60 And then I run my tests. I use Dart so I do pub run test test/selenium/custom_component_test.dart But now i'm trying use selenium 3. I have downloaded it and substitute my old terminal call with new jar but seems I can do it. Selenium tells me it doesn't know such parameter "-Dwebdriver.chrome.driver". And in help I can't see parameters to specify

How to run selenium 3.x with chrome driver through terminal

我们两清 提交于 2019-12-01 17:19:56
问题 May be it's easy question but I can't find any info about that. I used to run selenium 2.x as that way. I start server: java -jar selenium-server-standalone-2.53.1.jar -Dwebdriver.chrome.driver=chromedriver -browserSideLog -debug -timeout 60 And then I run my tests. I use Dart so I do pub run test test/selenium/custom_component_test.dart But now i'm trying use selenium 3. I have downloaded it and substitute my old terminal call with new jar but seems I can do it. Selenium tells me it doesn't

Set dummy IP address in integration test with Asp.Net Core TestServer

妖精的绣舞 提交于 2019-12-01 15:19:01
I have a C# Asp.Net Core (1.x) project, implementing a web REST API, and its related integration test project, where before any test there's a setup similar to: // ... IWebHostBuilder webHostBuilder = GetWebHostBuilderSimilarToRealOne() .UseStartup<MyTestStartup>(); TestServer server = new TestServer(webHostBuilder); server.BaseAddress = new Uri("http://localhost:5000"); HttpClient client = server.CreateClient(); // ... During tests, the client is used to send HTTP requests to web API (the system under test) and retrieve responses. Within actual system under test there's some component

Spring Boot. @DataJpaTest H2 embedded database create schema

和自甴很熟 提交于 2019-12-01 15:09:48
I have couple of entities in my data layer stored in particular schema. For example: @Entity @Table(name = "FOO", schema = "DUMMY") public class Foo {} I'm trying to setup H2 embedded database for integration testing of my data layer. I'm using @DataJpaTest annotation for my tests to get H2 embedded database configured automatically. However, the creation of tables fails because schema DUMMY is not created at DB initialization. Any ideas on how to create schema before creation of tables in test cases? I've tried to use @Sql(statements="CREATE SCHEMA IF NOT EXISTS DUMMY") but didn't succeed.

Java test class with many private methods

前提是你 提交于 2019-12-01 15:07:50
问题 I have a class that has the responsibility of importing contracts from a CSV to database. The class itself has only one public method that starts the import and the other methods are all private (because only the class itself will use, and they hold the logic). I'm starting to make tests for this class using Spock and there are many private methods, how should I test it? Should I turn them into public to test? Test only the main method, the public one? Whats the best? 回答1: In theory, your

How to return a value when using execute_script in capybara?

一个人想着一个人 提交于 2019-12-01 14:56:19
I have a really simple line in a test that calls execute script like this: puts page.execute_script("return somefunction();").to_i.inspect And in javascript I have a function like this: function somefunction(){ console.log("test"); return 999; } The 'test' from the console log is getting logged out so it is running however... Looking at the logs when running the test, the execute_script returns 0 not 999, so in rspec I can't get at the return value from the function, how do I make page.execute_script return that value from that function? The Poltergeist driver is designed to return nil for

How to return a value when using execute_script in capybara?

☆樱花仙子☆ 提交于 2019-12-01 13:41:32
问题 I have a really simple line in a test that calls execute script like this: puts page.execute_script("return somefunction();").to_i.inspect And in javascript I have a function like this: function somefunction(){ console.log("test"); return 999; } The 'test' from the console log is getting logged out so it is running however... Looking at the logs when running the test, the execute_script returns 0 not 999, so in rspec I can't get at the return value from the function, how do I make page