testing

Loop through links on a page in Codeception Tests

允我心安 提交于 2019-12-24 15:10:02
问题 I'm writing some functionality tests using Codeception and the PHPBrowser webdriver. Codeception uses specific references in CSS or XPath to check elements on a page. But I want to be able to loop through all the links in my menu, click on it and run a test to see if the link is working. ie. if my menu looks like this: <ul id='nav'> <li><a>Link1</a></li> <li><a>Link2</a></li> <li><a>Link3</a></li> <li><a>Link4</a></li> <li><a>Link5</a></li> </ul> I want to be able to loop through the links

Rspec it{} evaluated uses last variable value

独自空忆成欢 提交于 2019-12-24 15:09:10
问题 I'm using Rspec to make some tests for my program. In a spec I instantiate the class once, and perform my tests on it using describes and contexts . I encountered something interesting, if the its seem to be evaluated at the end of the contexts. For example given the following classes and its associated spec: class Tmp def initialize @values = {} end def modify(new_value1, new_value2) @values = {:a => new_value1, :b => new_value2} end def get_values return @values end end describe Tmp do tmp

how to emulate parallel multi-user usability testing with django and selenium/grid?

≡放荡痞女 提交于 2019-12-24 14:51:04
问题 I can get my Selenium tests running fine for one user/ sequentially on Django 1.4 using LiveServerTestCase, but I would like to emulate parallel multi-user testing. I don't think I need real load testing, since my apps are mostly moderate/low traffic web-sites and internal web-apps, so I would prefer to avoid extra tools like JMeter. I've started out setting up Selenium Grid but am not sure how to keep my tests independent and still run multiple tests with multiple users. I assume the test

grailsApplication not available in Domain class when running all Integration tests

折月煮酒 提交于 2019-12-24 14:49:27
问题 I'm running into a problem when running integration tests in Grails. One of the domain classes in the project has a method that accesses the grailsApplication.config property. We have an integration test for one of our services that call this method in the domain class. When the test is run on its own using the command grails test-app integration: com.project.MyTestSpec The test runs fine and the domain class can access grailsApplication . However when the whole test suite is run using:

Mocking EntityManager

余生长醉 提交于 2019-12-24 14:41:55
问题 I am getting NPE while mocking EntityManager, below is my code, @Stateless public class NodeChangeDeltaQueryBean implements NodeChangeDeltaQueryLocal { @PersistenceContext private EntityManager em; @Override public String findIdByNaturalKey(final String replicationDomain, final int sourceNodeIndex, final int nodeChangeNumber) { List<String> result = NodeChangeDelta.findIdByNaturalKey(this.em, replicationDomain, sourceNodeIndex, nodeChangeNumber).getResultList(); return result.isEmpty() ? null

How to test multiple version of google chrome using chromedriver?

无人久伴 提交于 2019-12-24 14:34:46
问题 selenium web-driver with java then how to use chrome driver for test their lower version of Google chrome 回答1: From the official wiki page: Overriding the Chrome binary location You can specify the location of the Chrome binary by passing the "chrome.binary" capability, e.g. with a typical Chromium install on Debian: DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability("chrome.binary", "/usr/lib/chromium-browser/chromium-browser"); WebDriver driver = new

How do I write a unit test for OSError?

大憨熊 提交于 2019-12-24 14:25:15
问题 I have the following python code which I want to test: def find_or_make_logfolder(self): if not path.isdir(self.logfolder): try: makedirs(self.logfolder) except OSError: if not path.isdir(self.logfolder): raise I want to do something like the following in my unittest. def test_find_or_make_logfolder_pre_existing(self): with self.assertRaises(OSError): makedirs(self.logfolder) find_or_make_logfolder() However, if not path.isdir(self.logfolder): is checking if the directory already exists or

How to test factory pattern using Mocha in Ruby?

為{幸葍}努か 提交于 2019-12-24 13:16:15
问题 I'm having trouble getting this simple mocha test to work Diclaimer I'm new to mocha! My Factory class # lib/fabtory.rb class Factory def self.build klass, *args klass.new *args end end My test code # test/test_factory.rb class FactoryTest < MiniTest::Unit::TestCase # my fake class class Fake def initialize *args end end def test_build_passes_arguments_to_constructor obj = Factory.build Fake, 1, 2, 3 obj.expects(:initialize).with(1, 2, 3).once end end Output unsatisfied expectations: -

Mocking in AWS Lambda

女生的网名这么多〃 提交于 2019-12-24 13:06:50
问题 I have a simple AWS Node.js Lambda, which I would like to test using mocks: //SimpleLambda.js var AWS = require('aws-sdk'); exports.handler = function(event, context) { var name = getName(); context.succeed(name); }; function getName() { return 'David'; } I've installed mocha and simple-mock , but I am unable to get this to work: //test.js //Mocha var assert = require('assert'); //Chai var chai = require('chai'); var expect = chai.expect; var should = chai.should(); //Simple-Mock var simple =

mocha and nested objects

谁说胖子不能爱 提交于 2019-12-24 12:50:39
问题 Excuse if this is a silly question, I am new to mocking. I am able to use mocha to do things like: person.expects(:first_name).returns('David') How can I mock a nested object? Say I have a Product that belongs to a Person and I want to get the first name of that person. In my app I might do it like this: product.person.first_name How would I get the same result using a mock? 回答1: as an alternative to shingara's answer, you could use mocha's any_instance method "which will detect calls to any