integration-testing

Database integration tests

允我心安 提交于 2019-12-05 20:07:28
问题 When you are doing integration tests with either just your data access layer or the majority of the application stack. What is the best way prevent multiple tests from clashing with each other if they are run on the same database? 回答1: Transactions. What the ruby on rails unit test framework does is this: Load all fixture data. For each test: BEGIN TRANSACTION # Yield control to user code ROLLBACK TRANSACTION End for each This means that Any changes your test makes to the database won't

JUnit custom runner with Spring application context

别等时光非礼了梦想. 提交于 2019-12-05 19:47:24
问题 I am fairly new to Spring and am working with a suite of JUnit 4.7 integration tests for a web application. I have a number of working test cases of the form: import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/META-INF/spring/testContext.xml" }) public class myTest { @Test public

Integration tests for AspectJ

醉酒当歌 提交于 2019-12-05 15:52:19
I am trying to write Integratation tests for Custom Aspect. Here is the Aspect Class Snippet. @Aspect @Component public class SampleAspect { private static Logger log = LoggerFactory.getLogger(SampleAspect.class); private int count; public int getCount(){ return count; } public void setCount(){ this.count= count; } @Around("execution(* org.springframework.data.mongodb.core.MongoOperations.*(..)) || execution(* org.springframework.web.client.RestOperations.*(..))") public Object intercept(final ProceedingJoinPoint point) throws Throwable { logger.info("invoked Cutom aspect"); setCount(1);

Does a Middle Ground Exist? (Unit Testing vs. Integration Testing)

拜拜、爱过 提交于 2019-12-05 15:41:57
Consider an implementation of the Repository Pattern (or similar). I'll try to keep the example/illustration as succinct as possible: interface IRepository<T> { void Add(T entity); } public class Repository<T> : IRepository<T> { public void Add(T entity) { // Some logic to add the entity to the repository here. } } In this particular implementation, the Repository is defined by an interface IRepository to have one method which adds an entity to the repository, thus making Repository dependant upon the generic type T (also, the Repository must be implicitly dependant upon another type

How do I access a MessageBox with white?

耗尽温柔 提交于 2019-12-05 15:29:05
I have a simple message box in a WPF application that is launched as below: private void Button_Click(object sender, RoutedEventArgs e) { MessageBox.Show("Howdy", "Howdy"); } I can get white to click my button and launch the message box. UISpy shows it as a child of my window I couldn't work out the method to access it. How do I get access to my MessageBox to verify its contents? Found it! The window class has a MessageBox method that does the trick: var app = Application.Launch(@"c:\ApplicationPath.exe"); var window = app.GetWindow("Window1"); var helloButton = window.Get<Button>("Hello");

how to test the CRUD service which only invoke the repository (dao) layer?

爷,独闯天下 提交于 2019-12-05 14:29:47
for example, we have a layer of service that simple invoke the JpaRepository method. usual crud public List<User> findAll() { return userRepository.findAll(); } how to correctly test such methods? just that the service invokes the dao layer? @Mock private UserRepository userRepository; @Test public void TestfindAllInvokeUserServiceMethod(){ userService.findAll(); verify(userRepository.findAll()); } upd: ok, findAll() is simple example, when we using when(userRepository.findAll()).thenReturn(usersList); we are actually doing only a test coverage, testing the obvious things. and a question. do

How to write integration test for asp.net web api

夙愿已清 提交于 2019-12-05 14:25:24
I am busy design a web service with asp.net web api. And I want to start doing unit tests on each controller. here is my test class so far: [TestClass] public class MyDevicesControllerTest { [TestMethod] public void TestValidUser() { MyDeviceController controller = new MyDeviceController(); var result = controller.Get(); } [TestMethod] public void TestInvalidUser() { MyDeviceController controller = new MyDeviceController(); var result = controller.Get(); } } But my web service makes use of token authentication. So I some how need to emulate the authentication process. So I was thinking my i

Any better alternative to Groovy for Java integration testing? [closed]

五迷三道 提交于 2019-12-05 13:34:56
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 months ago . I am planning to test my Java-based web application using its programming interfaces. To this aim, I intend to call my session beans using their RMI/WebService interfaces and check if their supported services are correct or not. To do this, I need a scripting language to: Call my RMI/WebService interfaces Execute SQL statements (e.g. for cleaning the DB at first) Have a simple flow control (loops, conditions,

How to set the ignore_ssl_errors option for Capybara Webkit in spec_helper.rb

笑着哭i 提交于 2019-12-05 12:48:05
In my spec_helper file I have: Capybara.javascript_driver = :webkit capybara_webkit now has a ignore_ssl_errors option that I want to use. How do I specify that in my spec_helper? Here's how to register the :webkit driver with the :ignore_ssl_errors option. Capybara.register_driver :webkit do |app| Capybara::Driver::Webkit.new(app, :ignore_ssl_errors => true) end As of writing (capybara-webkit 1.7.1), the configuration seems to have been simplified: Capybara::Webkit.configure do |config| config.ignore_ssl_errors end (source) Somehow the above register_driver examples don't work with Capybara 1

@DirtiesContext tears context down after every cucumber test scenario, not class

故事扮演 提交于 2019-12-05 11:28:05
Integration test executed by cucumber tends to leave behind context that causes problems with subsequent tests. Obvious solution appeared to be Spring's @DirtiesContext , but instead of tearing down the context after all the cucumber features have been run, it does this after each and every scenario, thus making the test execution time rather lengthy. Tried also with @TestExecutionListeners , but no luck. @RunWith( SpringJUnit4ClassRunner.class ) @ContextConfiguration( classes = { MyApplication.class, MyTestComponent.class }, loader = SpringApplicationContextLoader.class ) @ActiveProfiles( {