integration-testing

How to unit test code that requires user input c#

…衆ロ難τιáo~ 提交于 2020-08-10 19:35:14
问题 its my first time doing unit tests/integration tests and I have a question. So I started doing unit tests for my code, but I have a method, which is actually the logic of the whole application, where multiple methods are called, and user input is required. How can I test that method? Here is the method: public async Task RunAsync() { var watch = System.Diagnostics.Stopwatch.StartNew(); var playAgain = 'y'; do { var attempts = 1; var foundNumber = false; while (attempts < 10 && foundNumber ==

How to unit test code that requires user input c#

限于喜欢 提交于 2020-08-10 19:35:10
问题 its my first time doing unit tests/integration tests and I have a question. So I started doing unit tests for my code, but I have a method, which is actually the logic of the whole application, where multiple methods are called, and user input is required. How can I test that method? Here is the method: public async Task RunAsync() { var watch = System.Diagnostics.Stopwatch.StartNew(); var playAgain = 'y'; do { var attempts = 1; var foundNumber = false; while (attempts < 10 && foundNumber ==

Accessing session in integration test

六月ゝ 毕业季﹏ 提交于 2020-08-08 12:25:06
问题 I'm a Rails beginner working through Michael Hartl's Rails Tutorial and am receiving an error I have no idea how to fix. For reference, this is for implementing the changes in listing 9.24 (https://www.railstutorial.org/book/advanced_login). I skipped chapter 9 (since it is supposedly optional) but in Chapter 10 it asks to include the changes made in listing 9.24 so I did and my tests are still failing. This is the error I am receiving when I run rails test Error: UsersEditTest#test

Accessing session in integration test

不羁岁月 提交于 2020-08-08 12:24:23
问题 I'm a Rails beginner working through Michael Hartl's Rails Tutorial and am receiving an error I have no idea how to fix. For reference, this is for implementing the changes in listing 9.24 (https://www.railstutorial.org/book/advanced_login). I skipped chapter 9 (since it is supposedly optional) but in Chapter 10 it asks to include the changes made in listing 9.24 so I did and my tests are still failing. This is the error I am receiving when I run rails test Error: UsersEditTest#test

IllegalArgumentException: No visible constructors in class TestDatabaseAutoConfiguration$EmbeddedDataSourceFactoryBean

你离开我真会死。 提交于 2020-08-07 06:06:33
问题 I am trying to write an integration test for a spring boot JPA application using h2 database. Somehow TestEntityManager is not getting created. I tried look for some help on the forum but could not find any relevant information. Appreciate if anybody can help or provide some direction. Thanks. My code is as follows: Repository: @Repository public interface ConfigRepository extends JpaRepository<Config, Long> { Config findByKey(ConfigKey configKey); } Configuration: @Configuration

How to get TempData in an integration test

狂风中的少年 提交于 2020-08-07 04:53:27
问题 I have a controller with the following actions: [HttpGet] public IActionResult Index() { return View(); } [HttpPost] [Route( "/MyShop/OrderDetails/CancelOrder", Name = UrlRouteDefinitions.MyShopOrderDetailsCancelOrder)] [ValidateAntiForgeryToken] public IActionResult CancelOrder(MyViewModel viewModel) { var isCancelSuccessful = _orderBusinessLogic.CancelOrderById(viewModel.Order.Id); if (isCancelSuccessful) { //to show a success-message after the redirect this.TempData["SuccessCancelOrder"] =

Deploying microservice to be tested within the test

ⅰ亾dé卋堺 提交于 2020-07-30 05:51:50
问题 Maybe this is not possible to do generically in a test framework but I would like to be able to deploy the microservice I am testing within the test itself. I have looked at Citrus, RestAssured, and Karate and listened to countless talks and read countless blogs but I never see how to do this first stage. It always seems to be the case that there is an assumption that the microservice is pre-deployed. 回答1: Honestly it depends on how your microservice is deployed and which infrastructure you

Mongo in testcontainers

∥☆過路亽.° 提交于 2020-07-23 08:05:07
问题 I started playing with testcontainers and at the beginning of my journey I faced some issue (below). I did similar thing for mysql db and it worked fine. Do I miss some mongo specific config? According to [docs][1] there is not much to do. Thanks in advance for any tips / examples. com.mongodb.MongoSocketOpenException: Exception opening socket at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:70) ~[mongodb-driver-core-3.11.2.jar:na] at com.mongodb.internal.connection

Mongo in testcontainers

孤街浪徒 提交于 2020-07-23 08:03:09
问题 I started playing with testcontainers and at the beginning of my journey I faced some issue (below). I did similar thing for mysql db and it worked fine. Do I miss some mongo specific config? According to [docs][1] there is not much to do. Thanks in advance for any tips / examples. com.mongodb.MongoSocketOpenException: Exception opening socket at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:70) ~[mongodb-driver-core-3.11.2.jar:na] at com.mongodb.internal.connection

Mongo in testcontainers

六眼飞鱼酱① 提交于 2020-07-23 08:03:03
问题 I started playing with testcontainers and at the beginning of my journey I faced some issue (below). I did similar thing for mysql db and it worked fine. Do I miss some mongo specific config? According to [docs][1] there is not much to do. Thanks in advance for any tips / examples. com.mongodb.MongoSocketOpenException: Exception opening socket at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:70) ~[mongodb-driver-core-3.11.2.jar:na] at com.mongodb.internal.connection