testing

Symfony2 functional test client force server param SERVER_NAME

[亡魂溺海] 提交于 2020-01-16 05:25:07
问题 I designed a multiste app. There is multisite admin (ie. http://root.com/admin) and also all sites access (ie http://site1.com, http://site2.com...). To handle routing (multisite admin or child sites), I set the UseCanonicalName on vhost configuration : ServerName root.com ServerAlias media.site1.com site1.com media.site2.com, site2.com ... UseCanonicalName On Doing so, I'm sure that $request->server->get('SERVER_NAME') will always return in given case root.com, and I use this in routing

Protractor get element by model in repeater array

假如想象 提交于 2020-01-16 05:20:32
问题 For example, in HTML page: <tr ng-repeat="post in posts"> <td ng-click="activePost(post)" class="title">{{post.title}}</td> <td><button class="btn btn-danger" ng-click="delete(post)">Delete</button></td> <td><input type="checkbox" ng-model="post.active" id="{{post.id}}" /></td> </tr> Then, I want something like: element.all(by.repeater('post in posts')).then(function(posts) { var activePost = posts[0].element(by.model('active')); expect(activePost).toEqual(true); }); This returns an unable to

EvoSuite - Parameters For Getting Most Code Coverage

China☆狼群 提交于 2020-01-16 03:53:09
问题 I'm generating unit tests with EvoSuite and would like to get as close to 100% code coverage from the resulting unit tests as possible. What are the best command line options/parameters to set to accomplish this? 回答1: EvoSuite comes with its parameters already tuned. if you want to improve coverage further, you d need to increase the allotted time for test generation (eg by using -Dsearch_budget parameter), although that cannot guarantee 100% coverage. For more info, see http://www.evosuite

Cannot find Data Generation Plan in Visual Studio

不羁的心 提交于 2020-01-15 12:38:41
问题 I have created SQL Server database by Visual Studio 2010 Ultimate means in Visual Studio project. I would like to fill it by test data automatically. Msdn says I should create a new item of Data Generation Plan. But I cannot find Data Generation Plan in new item menu... What did I miss? )) 回答1: Have you tried http://msdn.microsoft.com/en-us/library/aa833267.aspx ? Sorry, can't post comments yet...... 来源: https://stackoverflow.com/questions/10963778/cannot-find-data-generation-plan-in-visual

JUnit initialization of static fields

帅比萌擦擦* 提交于 2020-01-15 11:22:53
问题 I'm using JUnit for unit testing. Let's say I want to test class B (methods of class B ). Let's say we have another class A which is the main class (contains main method) and has some protected static fields. Now, it is the case that class B uses some of these static fields of class A . So if I'm testing class B these static fields of class A does not exist. How can I test class B without executing the program (executing class A )? Edit: I have to clarify it. Let's assume we have the

How to disable a try/except block during testing?

 ̄綄美尐妖づ 提交于 2020-01-15 11:13:08
问题 I wrote a cronjob that iterates through a list of accounts and performs some web call for them (shown below): for account in self.ActiveAccountFactory(): try: self.logger.debug('Updating %s', account.login) self.update_account_from_fb(account) self.check_balances() self.check_rois() except Exception,e: self.logger.exception(traceback.format_exc()) Because this job is run by heroku one every 10 minutes, I do not want the entire job to fail just because one account is running into issues (it

Skip certain steps in a scenario in Cucumber

岁酱吖の 提交于 2020-01-15 08:23:21
问题 I have a cuke scenario, Scenario: Hello World Then do action one Then do action two Then do action three Then do action four Then do action five But depending on the environment variable, I want to skip action three and action four . I know I can go in the step and do a if-else check, but it's not very elegant. Is there any better solution? Thanks :) 回答1: You can't do this in Gherkin, nor should you want to! Gherkin is not for programming, nor is it for stating 'how' things are done, instead

how to mock global functions and classes used by another class

≯℡__Kan透↙ 提交于 2020-01-15 07:51:25
问题 I am trying to write a test, and one of my methods makes use of a global function web() which takes a (string) url, and creates and returns new instance of UrlHelper . This gives my app some shortcuts to some helper methods. (Yes DI would be better, but this is in a larvel app...) The method I'm trying to test, uses this global helper to get the content of the given url and compares it to another string. Using phpunit, how can i intercept the call to web or the creation of UrlHelper so i can

Find elements using css selector/xpath of Selenium Webdriver with Ruby

泄露秘密 提交于 2020-01-15 05:38:08
问题 I have recently started using Selenium to test an app having webviews. Well the code for my webview is: <div class="class1 class2 class3 class4" style="padding: 4px;" id="_6bd7b91a-214c-4075-b7db-dcaa08155e1a"> <span class="class5" style="font-weight: bold; text-decoration: underline;">This is TITLE</span> <div class="class6" dd:contenttype="content_type1" dd:concept="TITLE" id="_1d8c4490-d0c1-42ed-a93e-e92ca570dd32"> <div class="class7"> I am writing a re-usable code to find the element for

Browser detection using user agent in fixture hooks

旧时模样 提交于 2020-01-15 03:54:07
问题 I have a few tests that only need to be run when in a mobile browser. Currently I have a client function to check the user agent. const checkMobile = ClientFunction(() => /iPhone|Android/i.test(navigator.userAgent)) Which I then access inside my tests: test("Check if mobile", async t => { const isMobile = await checkMobile(); if (isMobile) { await t // do the tests } } Is there a way for me to use this in a fixture? Like a fixture which will only run if checkMobile is true ? So I don't need