w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » UNIT TESTING » Page 1
cabal: how to stop the build on test failure?
I just had to figure this out myself, this is what I finally got to work.... module Main where import Data.Monoid import Test.Framework import Test.Framework.Providers.HUnit import Test.HUnit firstTest::Assertion --This one passes

Categories : Unit Testing

Grails Neo4j - why is POM included as dependency?
I think you had a broken DNS server (e.g. in a Hotel/Hotspot) in your network when you first downloaded this (just view the neo4j-2.1.5.jar) which should be much much bigger. Remove that maven directory and try again on a sound network connection.

Categories : Unit Testing

What is NCover and how does it relate to NUnit?
NCover is a code-coverage tool that allows you to assess how much of your source code is "covered" by unit tests. The idea is that while you're running your unit tests with nUnit, nCover will be operating in the background, keeping track of each line of code that's being executed. After the tests are finished, nCover will show a visual report showing exactly which parts of your source code are a

Categories : Unit Testing

How to use the ANTLR 4 TestRig to show which lexer rule is used when tokenizing input?
I used the following test setup: grammar Begin; test: (BEGIN | ID)+; BEGIN : 'begin' ; ID : [a-z]+ ; WS : [ ]+ -> skip ; with ANTLRWorks 2.1. It works as expected: with 'begin': Arguments: [Begin, test, -tokens, -tree, -gui, C:ANTLRBegin.txt] [@0,0:4='begin',<1>,1:0] [@1,5:4='<EOF>',<-1>,1:5] (test begin) with 'beginning': Arguments: [Begin, test, -tokens, -tre

Categories : Unit Testing

UIApplication.sharedApplication().delegate as AppDelegate causes EXC_BAD_ACCESS using it on swift unit test
Make certain that your AppDelegate has "UIApplicationDelegate" in it's declaration. That is: @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { And if you're doing this for iOS, you might need to import UIKit at the top of this file.

Categories : Unit Testing

How to use Moq to Prove that the Method under test Calls another Method
"The only way I could think to do this is to use a mock for the class under test." I think you should not mock class under test. Mock only external dependencies your class under test has. What you could do is to create a testable-class. It would be a class which derives from your CUT and here you can catch the calls to the another method and verify it's parameter later. HTH Testable class in t

Categories : Unit Testing

MS Fakes unit tests failing after Visual Studio 2013 Update 4
In the reference properties for Microsoft.QualityTools.Testing.Fakes, change "Specific Version" property to FALSE. Doing so will allow VS2013 to use whatever version of Microsoft.QualityTools.Testing.Fakes is installed on your machine. With VS2013 Update 4, Microsoft incremented the version number of Microsoft.QualityTools.Testing.Fakes.dll from 11.0 to 12.0; this is what caused things to break.

Categories : Unit Testing

Grails Unit Testing: Mocking ApplicationContext
I found a way. I added the following lines to unit tests file. import org.springframework.mock.web.MockServletContext import org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes import org.codehaus.groovy.grails.web.context.ServletContextHolder @TestFor(BannedWordsService) class BannedWordsServiceTests { @Before void setUp(){ def servletContext = new MockServletCo

Categories : Unit Testing

Unit Testing HTTP traffic in Alamofire app
Waiting for an answer by @mattt I post an example of my code. Let's say that we have a Client class that is responsible for calling a simple web service. This class implements a function called userSignIn that performs a sign in using the WS. This is the code for the userSignIn function: func userSignIn( #email:String, password:String, completionHandler: (Bool, String?

Categories : Unit Testing

SOLID-principle attempt, solid or not solid?
Concerning the code you outlined above I definitely think you're on the right track. I would push the design a little further and define TransferOwnership as an additional interface. Following this approach your AppHandoverProcess is completely decoupled from it's client and the behaviour will be defined in the service configuration. Enforcing an isolation for the TransferOwnership will allow y

Categories : Unit Testing

Does Jasmine's spyOn() allow the spied on function to be executed?
It just creates a mock(spy) object and injects it to your tested code. It has three main purposes: Testing your code if it calls spy: toHaveBeenCalled Testing your code if it calls with appropriate parameters: toHaveBeenCalledWith Testing your code for different return values from spy: and.callThrough

Categories : Unit Testing

Parameter count mismatch in a Mocked method call
In the Returns clause of this Setup statement: mockedValidator.Setup(a => a.Validate( It.Is<MyType>(x => x.Id == Guid.Parse("3F2504E0-4F89-11D3-9A0C-0305E82C3301")), It.IsAny<Validazione.IMapper<MyType>>(), It.IsAny<ValidationConfiguration>() )).Returns<Validazione.ValidationResult>(x => x = It.IsAny<Validazione.ValidationResult>()); It

Categories : Unit Testing

Is NUnit 3 removing the 'classic' syntax for tests?
It is not removed in v3. Looking at the latest alpha 2 we can see that the methods Are* still exist in the Assert object eg public static void AreEqual(int expected, int actual) { Assert.That<int>(actual, Is.EqualTo(expected), null, null); } Old style tests is the prefixing of tests with "Test" (see also this launchpad)

Categories : Unit Testing

Loading a database in memory
I have solved this issue in a different way, by creating a RAM disk and creating the DB on the RAM disk. This has the advantage that as far as the DB thinks it is still on a disk, so nothing special is needed from the DB to support it, but everything is just done in memory. This sped up integration tests significantly for me. Ramdisk do a 32gb and 64gb version which should meet your needs, altho

Categories : Unit Testing

Grails Spock testing Controller and service
This is how I would do it in Grails 2.4, without annotation @Mock on the spec class: when: def serviceMock = mockFor(ApiService) serviceMock.demand.createCategory { def params -> "output sample" } controller.apiService = serviceMock.createMock() controller.createCategory()

Categories : Unit Testing

What are the best practices in testing a TitanDB graph
If your primarily unit testing traversals that read from the graph AND your graph data is static, then for a graph of that size you might consider loading it all once at the start of all tests then sharing that graph instance among your tests. If that is not the nature of your graph, then an in-memory instance is probably best as you can set that up and tear it down as needed. In short, from con

Categories : Unit Testing

Why it doesn't throw any exceptions when attempting to mock a singleton using either Mockito or PowerMock?
By using mocking, it means you are not testing the class itself, but want to dictate the behavior of the class so that it performs in an arbitrary way you want. The mock is only useful when you are trying to test some other class which has a dependency on the class being mocked. In your case, if you want to test the class being a Singleton, you should test on an REAL instance rather than a mock

Categories : Unit Testing

Gradlle test Unit tests - Run all except one or few - Command line
You could conditionally add an exclusion based on a property value. test { if (project.hasProperty('excludeTests')) { exclude project.property('excludeTests') } } You could then do something like this from the command line. $ gradle -DexcludeTests=org.foo.MyTest build

Categories : Unit Testing

TFS run unit tests failing because of missing files
In TFS 2013 you can execute a powershell pre-test to organize the files in a way that you need. You can get files to be deployed ad part of the tests with a test settings file for pre2013. If however the test setting file is not enough you can use the Community Build tools to call a powershell directly in previous versions to 2013. If you are stuck on 2012 then you will need to use the .testsett

Categories : Unit Testing

Error when running multiple unit tests with a MySQL database connection in Laravel
Your migrate and reset orders are invalid. Try this. public function setUp() { Artisan::call('migrate'); Artisan::call('db:seed'); } public function teardown() { Artisan::call('migrate:reset'); } Check this example. Note: Touching database while doing unit tests is not a good habit. I suggest to use mocks in your unit tests.

Categories : Unit Testing

How can I speed up my unit tests using cloud computing?
Running unit tests in parallel requires 2 things: Creating groups of multiple tests using either suites or JUnit categories A way to launch each group of tests Once you have #1, an easy way to get #2 is to use Continuous Integration. Do you already use Continuous Integration ? If not, it is easy to add. One of the more popular ones is Jenkins Jenkins also supports distributed builds where a

Categories : Unit Testing

Creating Fake for class that uses Prism and requests events with ThreadOption.UIThread
If you are using Nunit you can decorate your test fixture class with the RequiresSTA attribute and this will make testrunner use the UI thread and hopefully it should resolve the problem for you.

Categories : Unit Testing

Automatic layout tests
There is a way to automate layout testing of a web application using Galen Framework. This tool has its own language and is very easy to learn and understand. It is a Selenium based and you can run test in Selenium Grid, Sauce Labs if you want to test your application in different browsers. This tool gets the location of specified element on page and check them relatively to each other. Example:

Categories : Unit Testing

Unittesting Callable Orchestrations
It is hard to answer an open question with NO, but my answer would be that that it is not practically possible. Orchestrations are really tightly coupled with the BizTalk orchestration engine. If you want to unit test an orchestration, you will need to simulate that orchestration engine. That is not an easy job. There are a lot of specifics there that you have to think about, like dehydration, se

Categories : Unit Testing

Swift collections in unit tests
I came up with this solution: let protocols: AnyObject? = NSBundle.mainBundle().infoDictionary?["UISupportedExternalAccessoryProtocols"]; if let p = protocols as? [String] { XCTAssertTrue(contains(p, "foo")); XCTAssertTrue(contains(p, "bar")); } else { XCTFail("UISupportedExternalAccessoryProtocols must be an array"); } Is there a better way to handle it?

Categories : Unit Testing

Testing a function that takes an empty list
Well, the error tells you exactly what is wrong. Read it. The type variable `a0' is ambiguous So, type your variable! GHC can't possibly know what type to use to test unless you do. emptyListTest = TestCase $ assertEqual "for (func [])," [] $ func ([] :: [Int]) You may have to enable an extension to do it inline.

Categories : Unit Testing

Swift - Unit testing functions that involve IBOutlets?
You have to initiate the view controller using the storyboard. See the documentation here: https://developer.apple.com/library/ios/documentation/uikit/reference/UIStoryboard_Class/index.html#//apple_ref/occ/instm/UIStoryboard/instantiateViewControllerWithIdentifier: If you initialize the view controller directly, it will not have any connections because the VC itself does not know of the storyboa

Categories : Unit Testing

mock out return of a method base on the number of invocation only in spock
Yes it is possible. someObject.someMethod(*_) >>> [ 'x', 'y' ] It will return x on first invocation and y on second invocation of the method. Example: void "test something"() { given: def sample = Mock(Sample){ someMethod(_) >>> [ 'Hello', 'World' ] } expect: sample.someMethod( 'foo' ) == 'Hello' sample.someMethod( 'bar' ) == 'World' } class

Categories : Unit Testing

Grails Unit Test Failing
Until the domain instance is mocked in the test class, it won't be able to recognize dynamic methods like save() on the domain class. Use @Mock(Product) at class level in the test class.

Categories : Unit Testing

How to deal with unit-tests in Zend Framework 2?
Try adding this section in your composer.json "autoload": { "psr-0": { "AccessControlTest\": "tests/", "AccessControl\": "src/module/AccessControl/src/" } } And then run $ php composer.phar dump-autoload

Categories : Unit Testing

How to test implementations of Guice AbstractModule?
Typically the best way to test Guice modules is to just create an injector in your test and ensure you can get instances of keys you care about out of it. To do this without causing production stuff to happen you may need to replace some modules with other modules. You can use Modules.override to selectively override individual bindings, but you're usually better off just not installing "producti

Categories : Unit Testing

How do I mock a static method in final class
Most used testing framework is JUnit 4. So if you are using it you need to annotate test class with: @RunWith( PowerMockRunner.class ) @PrepareForTest( Class1.class ) Than PowerMockito.mockSatic(Class1.class); Mockito.doNothing().when(c1).doSomething(); Mockito.when(Class1.doSomething()).thenReturn(fakedValue); // call of static method is required to mock it PowerMockito.doNothing().when(Cl

Categories : Unit Testing

How to unit test a generator/serialization method?
This is more like a long comment with my first thoughts on the topic. I think you have to look at two different scenarios. Your data <-> serialized data relation could be either 1:1 or 1:n. XML would be a 1:n relation, where you XML code would have quite a little bit of freedom, but would still be unserialized to the same data again. In this case it seems to me, that developing and testing se

Categories : Unit Testing

How to test async code with angulardart
The test are executed inside a special zone (see lib/mock/zone.dart). Inside this zone, new Timer() will create a mock Timer and you need to call clockTick() to simulate clock ticks. See test/mock/zone_spec.dart for examples. Your test should probably look like clockTick(milliseconds: 1150); expect(ndom).toBeNull();

Categories : Unit Testing

SonarQube in intellij not picking up unit test branch coverage when running analysis
This is a known current limitation (that actually applies to both IntelliJ and Eclipse plugins): local analyses can't automatically execute unit tests, so they can't get the coverage results and give you the correct information. The reason for this is that local analyses are just "standard" analyses that don't push data to the server. And by definition, SonarQube analyses don't execute any exter

Categories : Unit Testing

How to test a method that starts my application?
I would say don't test that objects are created correctly. I presume you test the constructor for the Listener class in its own unit tests. Given that I would say you can trust the interpreter to construct your object correctly. If you want to test that the interpreter can construct classes then you're testing your scripting language not your app. If you want to functionally test the App class th

Categories : Unit Testing

Can we customize CakePHP test page?
The paths to the layout files (lib/Cake/TestSuite/templates) used are hard coded in the so called "reporter" used by the test suite, see the paint*() methods CakeHtmlReporter. It is however possible to hook in a custom reporter, by creating an appropriate reporter class named HtmlReporter in app/TestSuite/Reporter, ie app/TestSuite/Reporter/HtmlReporter.php If present, the test suite will use th

Categories : Unit Testing

Unit testing grails controllers that use declarative exception handling
I would test the fooService integration with your controller in an integration test if possible, but I think that's only really testable sensibly in a functional test. You're really testing Grails - you're verifying that documented behavior occurs in your app. If you add some code to throw an exception and then extra code to catch it and route it to the handler, you're just mocking out the stuff

Categories : Unit Testing

testify (Golang) seemingly running test suites concurrrently?
What I've found from my use, is that "go test" runs a single package's test cases sequentially (unless t.Parallel() is called), but if you supply multiple packages (go test ./foo ./bar ./baz), each package's tests are run parallel to other packages. Definitely caused similar headaches with database testing for me.

Categories : Unit Testing




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.