unit testing - Test clojure instance in deftest

I want to check if the right instance is used.But while the repl gives me true, the actual test returns nil.Idk why(ns my-app.queue)(def queue (atom clojure.lang.PersistentQueue/EMPTY))(ns my-app.queue-test (:require [my-app.queue :as sut] [clojure.test :refer :all]))(deftest queue-type-test (is (instance? clojure.lang.PersistentQueue @sut/queue)));repl output;(instance? clojure.lang.PersistentQueue @sut/queue) ;=> trueThe command lein test gives me:FAIL in (queue-type-test) (queue_test.clj:6)expected: (instance? clojure.lang.Pe...Read more

unit testing - How to link a Part from an RCP App to SWTBot?

I am starting to use SWTBot to test my application Eclipse RCP v4.This is my code, to get a part via an id and activate it.protected static void openPart(final String id) { Display.getDefault().syncExec(new Runnable() { public void run() { EPartService partService = E4Workbench.getServiceContext().getActiveLeaf().get(EPartService.class); MPart part = partService.findPart(id); partService.activate(part); } });}This is my tests. And it doesn't work... @Testpublic void test1() { openPart("tes...Read more

Mocking SQL for unit testing using MockFor in Groovy

Below code snippet is my unit test case code for Groovy class.While running this test case in Eclipse Luna using maven build getting below error: Errors: [ERROR] com.double.example.application.appMockTest#testUserList MissingMethodException Any one of you could please throw some light on this? How to fix this issue? Note: saw few online discussions but nothing worked out.public void testUserList() { setup() def userList = [['name':'12345678', 'actual_name':'Paul allan']] List<User> tempList = new Arra...Read more

unit testing - Mock is giving missing method exception in spock framewrok

I am running my Junit test cases for my groovy class using spock framework I am using Mock to invoke my class. but it is giving me MissingMethodException but if I invoke the same method by normal creating object def obj = new MyClass() way it is working. please let me know am I missing something? below is my stacktraceExpected no exception to be thrown, but got 'groovy.lang.MissingMethodException' at spock.lang.Specification.noExceptionThrown(Specification.java:119) at .AsplTest.fetchXmlTest(AsplTest.groovy:35)Caused by: groovy.lang.Missi...Read more

unit testing - Argument capturing on the insides of closures in Spock

I am trying to test a method that does an invocation with a closure, something like this:def foo(Long param) { AnObject.doSomething { bar(param) }}And I want to test that doSomething is called with a closure that calls bar with the expected value inside.I'm able to test properly the doSomething invocation by creating a spy and doingwhen: service.foo(1L)then: 1 * AnObject.doSomething{_}However, I cannot seem to find a way to perform assertions on the contents of the closure. What's the appropriate way to assert that inside the ...Read more

unit testing - How to write parametrized tests with groovy-spock using mocks

I want to test this class using groovy with spock:class TaskRunner { private int threads private ExecutorService executorService private TaskFactory taskFactory // relevant constructor void update(Iterable<SomeData> dataToUpdate) { Iterable<List<SomeData>> partitions = partition(dataToUpdate, THREADS) partitions.each { executorService.execute(taskFactory.createTask(it)) } }}I want to write test looking like this one:class TaskRunnerSpec extends specification { ExecutorServic...Read more

Automated Testing Tool for Json-Rpc?

Can anybody suggest a good tool for automated testing of json-rpc interfaces?We are using Json-RPC. We have looked at JMeter and The Grinder, but they don't seem to offer any slick way of testing ranges of arguments in our RPC calls. For example, with JMeter, we would have to set up a separate .json file for each set of parameters that we want to test.Are there any good tools out there for automated testing of json-rpc? We are looking for something with a GUI (like JMeter) as well as something that we can trigger from Jenkins.As a very contrive...Read more

unit testing - Amazon S3 standalone stub server

I seem to recall reading about an Amazon S3-compatible test server that you could run on your own server for unit tests or whatever. However, I've just exhausted my patience looking for this with both Google and AWS. Does such a thing exist? If not, I think I'll write one.Note: I'm asking about Amazon S3 (the storage system) rather than Amazon EC2 (cloud computing)....Read more

File handling in UWP unit tests

I have to setup some unit tests to run on UWP. The unit tests work with files on disk. The files location is configured as a full path (C:\Temp\ for example).I created a unit test application in Visual Studio 2015, in application manifest I checked Internet (Client), Private Networks and Removable Storage. I also setup a file association for my file type (.dat).When I run the tests I get Access Denied exceptions when the tests try to open the files on disk. The files are opened using the FileStream class.Exception Message: Test method UnitTests...Read more

Is Unit Testing worth the effort?

I am working to integrate unit testing into the development process on the team I work on and there are some sceptics. What are some good ways to convince the sceptical developers on the team of the value of Unit Testing? In my specific case we would be adding Unit Tests as we add functionality or fixed bugs. Unfortunately our code base does not lend itself to easy testing....Read more

unit testing - combining test.check and clojure test

I am having trouble to use test.check together with normal tests. I tried the whole day to figure out what is going on, but I am still not sure.This is what I have now:(deftest user-can-only-be-inserted-once (;normal test))(defspec insert-one-user-should-let-me-retrieve-that-one-user gen-quantity (prop/for-all ; test.check test))Now, as long as I execute "lein test" from the console after each change in the test file it works as expected. However, running tests from the cursive repl or with the quickie plugin via "lein quickie"...Read more

unit testing - clojure.test (is (thrown? ...) not seeing exception

I have a function param-values that throws an IllegalArgumentException when it cannot find a key in a Liberator context. I have a clojure.test unit test for this:(testing "Non-existing key" (is (thrown? IllegalArgumentException (param-values ctx [:baz]))))For some reason, this test is failing, even though I can see that my function is behaving correctly in the REPL:user> (param-values ctx [:baz])IllegalArgumentException Missing required param baz resources/param-value (resources.clj:57)user> (is (thrown? IllegalArgumentException (param...Read more

How to do unit testing of side-effects functions in Clojure?

This question is not about specific libraries (although some of them will be used in end), but more about how to structure your application code to make side-effects functions unit testing possible. If we should do it at all?Obviously, it is clear and simple to do testing of pure side-effects free functions, you pass the input, and you assert the output.There are 2 (very roughly) types of testing, unit and integration. Lets focus on unit testing here.So, if you have a function which reads from file or writes into files (using slurp/spit, for ex...Read more