testing

React, Jest and Material-UI: How to test for content rendered in a modal or popover

老子叫甜甜 提交于 2019-12-21 12:34:09
问题 There are a few material-ui components that do not render their results in the same place as the component is placed by their parent. Among these we have the Dialog , Menu , etc. This makes it apparently impossible to test for their content's presence in a jest.js wrapper with some parent component mounted in it. For example given the following component: class DropdownMenu extends React.Component { onButtonClick = (e) => { this.setState({ open: true, anchorEl: e.currentTarget }); } render()

call a specific url with rspec

瘦欲@ 提交于 2019-12-21 12:27:39
问题 I want to create a get request in rspec. get :exec, {:query=>"bla", :id => "something", :user_id => "user" } This builds a URL like: /user/query/something/exec?query=bla The thing is that my controller checks the request it gets and the url must look like: /user/query/something/_XXX_/exec?query=bla How can I do something like this in rspec? (The XXX is hard-coded in the routes.rb file.) 回答1: I'm assuming you're referring to a controller spec. When you pass in a hash like in your example, the

SQLite's test code to production code ratio

拈花ヽ惹草 提交于 2019-12-21 12:19:49
问题 SQLite claim to have 679 times more test code than production one. http://www.sqlite.org/testing.html Does anyone knows how it is possible? Do they generate any test code automatically? What are the major parts of these "45678.3 KSLOC" of test code? 回答1: "Does anyone knows how it is possible?" "It is possible" to have 679 times as much test code because a single feature can be used in many different ways. Consider just a single function that takes two parameters. I can generate alot of test

Generate a read error

我的未来我决定 提交于 2019-12-21 11:14:04
问题 It's simple to generate a write error in a test suite by writing to /dev/full . Is there a good technique to generate a read error? I'm currently using LD_PRELOAD to override read but that seems too complicated and non-portable (not that /dev/full is portable...). 回答1: Besides reading from a directory (as mentioned in a previous answer) you can try to read /proc/self/mem to get an error (this should get you an EIO on Linux). For an explanation, please see: https://unix.stackexchange.com/a

Getting QUnit to run tests in order

╄→尐↘猪︶ㄣ 提交于 2019-12-21 09:28:29
问题 I've used qunit to write a series of tests for javascript code I have. Right now for some reason, the first test in my list will run, and then the LAST test in the list runs, followed by the 2nd to last, 3rd to last, 4th to last, etc... It's crucial for my tests that things run in the order that I have them in. I tried turning off that option where qunit runs tests that failed last time first, but it's still doing this. Is there any way to fix this? 回答1: First, figure out why your tests MUST

In pytest, how to skip or xfail certain fixtures?

和自甴很熟 提交于 2019-12-21 09:23:20
问题 I have a heavily-fixtured test function which fails (as it should) with certain fixture inputs. How can I indicate this? This is what I'm doing now, and maybe there's a better way. I'm pretty new to py.test so I'd appreciate any tips. The next part is all the input fixtures. FYI, example_datapackage_path is defined in conf.test @pytest.fixture(params=[None, 'pooled_col', 'phenotype_col']) def metadata_key(self, request): return request.param @pytest.fixture(params=[None, 'feature_rename_col']

In pytest, how to skip or xfail certain fixtures?

◇◆丶佛笑我妖孽 提交于 2019-12-21 09:23:18
问题 I have a heavily-fixtured test function which fails (as it should) with certain fixture inputs. How can I indicate this? This is what I'm doing now, and maybe there's a better way. I'm pretty new to py.test so I'd appreciate any tips. The next part is all the input fixtures. FYI, example_datapackage_path is defined in conf.test @pytest.fixture(params=[None, 'pooled_col', 'phenotype_col']) def metadata_key(self, request): return request.param @pytest.fixture(params=[None, 'feature_rename_col']

sinon stub not replacing function.

痴心易碎 提交于 2019-12-21 09:22:10
问题 I tried a dummy module and to stub it, but does not work. the app.js function foo() { return run_func() } function run_func() { return '1' } exports._test = {foo: foo, run_func: run_func} the test.js app = require("./app.js")._test describe('test', function(){ it('test', function(){ var test_stub = sinon.stub(app, 'run_func').callsFake( function(){ return '0' }) test_stub.restore() var res = app.foo() assert.equal('0', res) }) }) I tried the advice from: sinon stub not replacing function But

How to test that a function is called within a function with nosetests

被刻印的时光 ゝ 提交于 2019-12-21 08:08:33
问题 I'm trying to set up some automatic unit testing for a project. I have some functions which, as a side effect occasionally call another function. I want to write a unit test which tests that the second function gets called but I'm stumped. Below is pseudocode example: def a(self): data = self.get() if len(data) > 3500: self.b() # Bunch of other magic, which is easy to test. def b(self): serial.write("\x00\x01\x02") How do I test that b() -gets called? 回答1: You can mock the function b using

Java detect if class is a proxy

旧城冷巷雨未停 提交于 2019-12-21 07:55:50
问题 Is it possible to detect if a class is a proxy ( dynamic , cglib or otherwise )? Let classes A and B implement a common interface I . Then I need to define a routine classEquals of signature public boolean classEquals(Class<? extends I> a, Class<? extends I> b); such that it evaluates to true only if a.equals(b) or Proxy(a).equals(b) , where Proxy(a) denotes a dynamic proxy of type A (dynamic, cglib or otherwise). With the assistance of @Jigar Joshi , this is what it looks like so far: public