Should one test internal implementation, or only test public behaviour?

The answer is very simple: you are describing functional testing, which is an important part of software QA. Testing internal implementation is unit-testing, which is another part of software QA with a different goal. That’s why you are feeling that people disagree with your approach. Functional testing is important to validate that the system or … Read more

Database data needed in integration tests; created by API calls or using imported data?

I prefer creating the test data using API calls. In the beginning of the test, you create an empty database (in-memory or the same that is used in production), run the install script to initialize it, and then create whatever test data used by the database. Creation of the test data may be organized for … Read more

how to test react-select with react-testing-library

In my project, I’m using react-testing-library and jest-dom. I ran into same problem – after some investigation I found solution, based on thread: https://github.com/airbnb/enzyme/issues/400 Notice that the top-level function for render has to be async, as well as individual steps. There is no need to use focus event in this case, and it will allow … Read more

Integration Testing POSTing an entire object to Spring MVC controller

I had the same question and it turned out the solution was fairly simple, by using JSON marshaller. Having your controller just change the signature by changing @ModelAttribute(“newObject”) to @RequestBody. Like this: @Controller @RequestMapping(value = “/somewhere/new”) public class SomewhereController { @RequestMapping(method = RequestMethod.POST) public String post(@RequestBody NewObject newObject) { // … } } Then in … Read more

How to keep Unit tests and Integrations tests separate in pytest

Yes, you can mark tests with the pytest.mark decorator. Example: def unit_test_1(): # assert here def unit_test_2(): # assert here @pytest.mark.integtest def integration_test(): # assert here Now, from the command line, you can run pytest -m “not integtest” for only the unit tests, pytest -m integtest for only the integration test and plain pytest for … Read more

How to test file inputs with Cypress?

it(‘Testing picture uploading’, () => { cy.fixture(‘testPicture.png’).then(fileContent => { cy.get(‘input[type=”file”]’).attachFile({ fileContent: fileContent.toString(), fileName: ‘testPicture.png’, mimeType: ‘image/png’ }); }); }); Use cypress file upload package: https://www.npmjs.com/package/cypress-file-upload Note: testPicture.png must be in fixture folder of cypress