testing

Android Robotium NoClassDefFoundError

陌路散爱 提交于 2019-12-30 05:56:36
问题 I was just trying to use Robotium in an Android JUnit Test, but the Testing always fails with an error: java.lang.NoClassDefFoundError: com.jayway.android.robotium.solo.Solo thrown at solo = new Solo(getInstrumentation(), getActivity()); in the setUp() method: protected void setUp() throws Exception { super.setUp(); solo = new Solo(getInstrumentation(), getActivity()); } I read somewhere that this could be related to the Android SDK revision 17, but I cannot confirm this, as I first tried

Verify a file exists over ssh

可紊 提交于 2019-12-30 05:02:45
问题 I am trying to test if a file exists over SSH using pexpect. I have got most of the code working but I need to catch the value so I can assert whether the file exists. The code I have done is below: def VersionID(): ssh_newkey = 'Are you sure you want to continue connecting' # my ssh command line p=pexpect.spawn('ssh service@10.10.0.0') i=p.expect([ssh_newkey,'password:',pexpect.EOF]) if i==0: p.sendline('yes') i=p.expect([ssh_newkey,'password:',pexpect.EOF]) if i==1: p.sendline("word") i=p

Stubbing WebSocket in JavaScript with Jasmine

≡放荡痞女 提交于 2019-12-30 04:50:05
问题 I try to test if onmessage is a proper function. Here is a test: describe(".init(address, window)", function() { beforeEach(function() { address = 'ws://test.address'; window = {}; e = { data: {} } spyOn(window, 'WebSocket').and.returnValue(function() {return {onmessage: null}}); spyOn(subject, 'handleMessage'); }); it("should create a WebSocket client which connects to the given address", function() { subject.init(address, window); expect(window.WebSocket).toHaveBeenCalledWith(address); });

How do I test for an error in Haskell?

白昼怎懂夜的黑 提交于 2019-12-30 04:37:05
问题 I want to be able to make sure a function will throw an error when it receives and invalid value. For example, let says I have a function pos that only returns a positive number: pos :: Int -> Int pos x | x >= 0 = x | otherwise = error "Invalid Input" This is a simplistic example, but I hope you get the idea. I want to be able to write a test case that will expect an error and consider it a passing test. For example: tests = [pos 1 == 1, assertError pos (-1), pos 2 == 2, assertError pos (-2)]

How to test the passing of arguments in Golang?

假如想象 提交于 2019-12-30 04:06:21
问题 package main import ( "flag" "fmt" ) func main() { passArguments() } func passArguments() string { username := flag.String("user", "root", "Username for this server") flag.Parse() fmt.Printf("Your username is %q.", *username) usernameToString := *username return usernameToString } Passing an argument to the compiled code: ./args -user=bla results in: Your username is "bla" the username that has been passed is displayed. Aim: in order to prevent that the code needs to be build and run manually

Unit Test a file upload, how?

試著忘記壹切 提交于 2019-12-30 04:00:15
问题 Using MVC3.NET I have a file upload method in a controller that works fine with the following signature public ActionResult UploadFile(IEnumerable<HttpPostedFileBase> file) How can I unit test this with NUnit? I have looked around and everyone seems to point to Moq but I'm new to unit testing and cannot get Moq working. I have found interesting blogs such as this: http://danielglyde.blogspot.com/2011/07/tdd-with-aspnet-mvc-3-moq-and.html but am struggling to figure out how the same might be

How to make py.test run doctests as well as normal tests directory?

我们两清 提交于 2019-12-30 03:47:09
问题 We currently have py.test with the coverage plugin running over our tests in a tests directory. What's the simplest way to also run doctests extracted from our main code? --doctest-modules doesn't work (probably since it just runs doctests from tests ). Note that we want to include doctests in the same process (and not simply run a separate invocation of py.test ) because we want to account for doctest in code coverage. 回答1: Now it is implemented :-). To use, either run py.test --doctest

Testing a gem that uses ActiveRecord models

雨燕双飞 提交于 2019-12-30 03:09:12
问题 I wrote a gem that imports data into your database if you pass in an ActiveRecord model. For example: importer = Importer.new(Widget) importer.import(data_source) Is there a good way to test this gem? I would somehow need to connect to a test database and create a test model. Thanks! 回答1: Mostly inspired from this post: http://blog.markstarkman.com/blog/2013/01/23/using-sqlite-to-test-active-record-models/ First, in your gemspec, you can add ActiveRecord and sqlite3 as dependencies like so:

Clear browser Cookies with Selenium WebDriver Java bindings

烈酒焚心 提交于 2019-12-30 02:45:11
问题 Does anyone know if it's possible to Clear Browser Cookies for WebDriver before starting the automation? (Note: Not Selenium RC) 回答1: Yes, it's possible driver.manage().deleteAllCookies(); Call it right after you are creating the new WebDriver instance. WebDriver driver = new ChromeDriver(); driver.manage().deleteAllCookies(); You can also delete the cookies one by one Set<Cookie> allCookies = driver.manage().getCookies(); for (Cookie cookie : allCookies) { driver.manage().deleteCookieNamed

Testing in django: what are differences between setUpClass, setUpTestData and setUp in TestCase class?

◇◆丶佛笑我妖孽 提交于 2019-12-30 02:44:25
问题 What are the differences between setUpClass , setUpTestData and setUp in the TestCase class? More specifically, what are the use cases for each? What I've understood so far: setUpClass This method runs once, before all the tests in a test class setUpTestData This method runs once if the DB has transaction support. Otherwise it runs before each test. setUp This method runs before each test in a test class. From the understanding I mentioned above, it seems setUpTestData lies in the area