integration-testing

Unit tests vs integration tests with Spring

不羁岁月 提交于 2019-11-28 16:31:27
I'm working on a Spring MVC project, and I have unit tests for all of the various components in the source tree. For example, if I have a controller HomeController , which needs to have a LoginService injected into it, then in my unit test HomeControllerTest I simply instantiate the object as normal (outside of Spring) and inject the property: protected void setUp() throws Exception { super.setUp(); //... controller = new HomeController(); controller.setLoginService( new SimpleLoginService() ); //... } This works great for testing each component as an isolated unit - except now that I have a

What are the pros and cons of automated Unit Tests vs automated Integration tests?

心不动则不痛 提交于 2019-11-28 16:23:52
Recently we have been adding automated tests to our existing java applications. What we have The majority of these tests are integration tests, which may cover a stack of calls like:- HTTP post into a servlet The servlet validates the request and calls the business layer The business layer does a bunch of stuff via hibernate etc and updates some database tables The servlet generates some XML, runs this through XSLT to produce response HTML. We then verify that the servlet responded with the correct XML and that the correct rows exist in the database (our development Oracle instance). These

How to do integration testing in .NET with real files?

微笑、不失礼 提交于 2019-11-28 16:11:22
问题 I have some classes that implements some logic related to file system and files. For example, I am performing following tasks as part of this logic: checking if certain folder has certain structure (eg. it contains subfolders with specific names etc...) loading some files from those folders and checking their structure (eg. these are some configuration files, located at certain place within certain folder) load additional files for testing/validation from the configuration file (eg. this

How to write unit tests for database calls

南笙酒味 提交于 2019-11-28 15:46:51
I'm near the beginning of a new project and (gasp!) for the first time ever I'm trying to include unit tests in a project of mine. I'm having trouble devising some of the unit tests themselves. I have a few methods which have been easy enough to test (pass in two values and check for an expected output). I've got other parts of the code which are doing more complex things like running queries against the database and I'm not sure how to test them. public DataTable ExecuteQuery(SqlConnection ActiveConnection, string Query, SqlParameterCollection Parameters) { DataTable resultSet = new DataTable

What are unit testing and integration testing, and what other types of testing should I know about?

不羁岁月 提交于 2019-11-28 15:39:41
I've seen other people mention several types of testing on Stack Overflow. The ones I can recall are unit testing and integration testing. Especially unit testing is mentioned a lot. What exactly is unit testing? What is integration testing? What other important testing techniques should I be aware of? Programming is not my profession, but I would like it to be some day;stuff about production etc is welcomed too. Steven A. Lowe Off the top of my head: Unit testing in the sense of "testing the smallest isolatable unit of an application"; this is typically a method or a class, depending on scale

Database data needed in integration tests; created by API calls or using imported data?

我只是一个虾纸丫 提交于 2019-11-28 15:31:05
This question is more or less programming language agnostic. However as I'm mostly into Java these days that's where I'll draw my examples from. I'm also thinking about the OOP case, so if you want to test a method you need an instance of that methods class. A core rule for unit tests is that they should be autonomous, and that can be achieved by isolating a class from its dependencies. There are several ways to do it and it depends on if you inject your dependencies using IoC (in the Java world we have Spring, EJB3 and other frameworks/platforms which provide injection capabilities) and/or if

Separating unit tests and integration tests in Go

匆匆过客 提交于 2019-11-28 15:10:44
Is there an established best practice for separating unit tests and integration tests in GoLang (testify)? I have a mix of unit tests (which do not rely on any external resources and thus run really fast) and integration tests (which do rely on any external resources and thus run slower). So, I want to be able to control whether or not to include the integration tests when I say go test . The most straight-forward technique would seem to be to define a -integrate flag in main: var runIntegrationTests = flag.Bool("integration", false , "Run the integration tests (in addition to the unit tests)"

How to use redirection in cmake add_test

我的梦境 提交于 2019-11-28 12:36:11
I have a console application called "foo", which takes a reference text file as input (in.txt) and generates text at standard output (I want to keep this behaviour). In make (not cmake), I use a test target, which calls foo and redirects the output to a file (out.txt) as follows. Then, I use diff to compare the file out.txt with the expected refernece (ref.txt) test: ./foo -a test/in.txt > test/out.txt diff test/out.txt test/ref.txt This works fine using make. Now my question is; how can I use cmake to create a similar Makefile? From within a subdrectory called build, I tried project(foo) ...

How to see the Android Orchestrator log?

℡╲_俬逩灬. 提交于 2019-11-28 12:01:34
I have a failing test in my suite and now I am using the Android Orchestrator, but all I get is this message: Test instrumentation process crashed. Check com.something.something_detail.SomeActivityTest#testAddSucceeds_activityIsFinished.txt for details I don't know how to access that file. Any help? Turnsole You'll find them on the device under /data/data/android.support.test.orchestrator/files/ . To get them off the device via ADB (requires debugging enabled and either a rooted device or an emulator so you have root): adb root adb pull /data/data/android.support.test.orchestrator/files/ Non

Jacoco Unit and Integration Tests coverage - individual and overall [closed]

落花浮王杯 提交于 2019-11-28 11:29:20
I have a project (ProjectA) which contains some unit tests and integration tests. Following is the structure. ProjectA - src/java (java source code) - test/java (Junit unit tests) - test/resources (resources required for Junit Unit tests) - src/java-test (Integration tests) - conf (contains .xml files required for building/testing/compiling purposes) I run the following commands -- All of them works but I have a doubt on how the configurations that I have in build.gradle / GRADLE_HOME/init.d/*.gradle files are affecting what I'm getting. It seems like I'm missing something and not getting