testing

FIFO semaphore test

旧时模样 提交于 2020-01-24 15:55:09
问题 I have implemented FIFO semaphores but now I need a way to test/prove that they are working properly. A simple test would be to create some threads that try to wait on a semaphore and then print a message with a number and if the numbers are in order it should be FIFO, but this is not good enough to prove it because that order could have occurred by chance. Thus, I need a better way of testing it. If necessary locks or condition variables can be used too. Thanks 回答1: What you describe with

Mock method from the same class that tested method is using

瘦欲@ 提交于 2020-01-24 14:34:40
问题 I have following code: class Foo() { public function someMethod() { ... if ($this->otherMethod($lorem, $ipsum)) { ... } ... } } and I'm trying to test the someMethod(), I don't want to test otherMethod() since it's quite complex and I have dedicated tests - here I would only like to mock it and return specific values. So I tried to: $fooMock = Mockery::mock(Foo::class) ->makePartial(); $fooMock->shouldReceive('otherMethod') ->withAnyArgs() ->andReturn($otherMethodReturnValue); and in test I'm

Mock method from the same class that tested method is using

会有一股神秘感。 提交于 2020-01-24 14:33:13
问题 I have following code: class Foo() { public function someMethod() { ... if ($this->otherMethod($lorem, $ipsum)) { ... } ... } } and I'm trying to test the someMethod(), I don't want to test otherMethod() since it's quite complex and I have dedicated tests - here I would only like to mock it and return specific values. So I tried to: $fooMock = Mockery::mock(Foo::class) ->makePartial(); $fooMock->shouldReceive('otherMethod') ->withAnyArgs() ->andReturn($otherMethodReturnValue); and in test I'm

@SpringBootTest for a non-spring-boot application

血红的双手。 提交于 2020-01-24 06:27:48
问题 I am creating a non-spring-boot application using spring-rest, spring-data-jpa etc and I would like to do integration testing using spring boot (1.4.1.RELEASE). Note that I don't have a SpringApplication class or @SpringApplication annotation anywhere On my test class I have @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = MyConfiguration.class) public class MyIT { } @RestController public class MyController { } This is

How to make custom iOS apps easier for Spotlight to find

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-24 04:24:11
问题 I write lots of little test apps on my devices. Is there some metadata I can add to the app so it appears more readily in Spotlight searches? For instance, I made a laundry timer app named Lavado Can I make it appear in Spotlight searches when I search for "timer" or "laundry"? This is not for the Apple App Store, just on my devices. 回答1: Spotlight searches both names as they appear in SpringBoard (your home screen) and their full App Store names. So if your application full name is "Lavado

How to skip certain tests with Test::Unit

对着背影说爱祢 提交于 2020-01-24 02:29:11
问题 In one of my projects I need to collaborate with several backend systems. Some of them somewhat lacks in documentation, and partly therefore I have some test code that interact with some test servers just to see everything works as expected. However, accessing these servers is quite slow, and therefore I do not want to run these tests every time I run my test suite. My question is how to deal with a situation where you want to skip certain tests. Currently I use an environment variable

Emberjs Testing a Component's action delegate

强颜欢笑 提交于 2020-01-24 01:07:21
问题 I'm trying to test a simple component that uses action delegation. I want to test that a certain action is sent to the actionDelegate of a component. I was thinking of using Sinon to check that the action was being sent, but I can't work out how to replicate the structure that Ember uses to send its actions to its delegates/targets. What structure would my sinon "spy delegate" object take in order for me to check that the component is delegating the event using "send" when the user clicks on

Exception message: no such file to load in rails application

久未见 提交于 2020-01-23 09:46:09
问题 I have included test_helper.rb under test in my rails application. I have even included require 'test_helper' in my test.rb files under test->unit . When I run all the test in RubyMine for the application, I get the following error: I have the latest versions of all RubyMine 3.2, ruby 1.9.2p290 and Rails 3.1.0. /Users/im/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb

Instrumented Unit Class Test - Can't create handler inside thread that has not called Looper.prepare()

隐身守侯 提交于 2020-01-23 09:05:01
问题 Sorry I've looked at tutorials all over the place and not found the answer I'm looking for. I'm following Google's Tutorial at the moment here: https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests.html I'm trying to create an Instrumented test and when I run it I'm getting the error : java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() So my test is as follows: package testapp.silencertestapp; import android

Gradle custom test sourceSet

混江龙づ霸主 提交于 2020-01-23 07:25:11
问题 I have a gradle project and have main and test as sourceSets. I do want test-main not to be part of test source sets. Now the issue I encounter is that when projects are build, the test-main is marked as Sources Root instead of Test Sources Root . This leads to compilation errors and I have to manually mark test-mains as Source Test Root for all subprojects. I created a task in order to enforce intellij to mark them as Sources Test Root but seems like I am doing something wrong. hints: