unit-testing

Question about Karate test case for POST method

五迷三道 提交于 2021-02-05 08:16:27
问题 I have an endpoint URL, within Swagger I must pass certain fields to test the POST method. I was wondering if anyone had an example of how to set up a Karate test for a POST method? 回答1: Yes, there are plenty in the documentation: https://github.com/intuit/karate If you follow the quickstart, you will get a sample project with a working POST: https://github.com/intuit/karate#quickstart Scenario: create a user and then get it by id * def user = """ { "name": "Test User", "username": "testuser"

Testing codepaths for older OS versions

牧云@^-^@ 提交于 2021-02-05 08:12:25
问题 If I have some library with methods like: public struct Foo { @available(macOS 10.15, *) func greatNewFeature() -> String { return "new feature" } func legacyFeature() -> String { return "legacy feature" } } Then some code that uses it: func methodToTest() -> String { let foo = Foo() guard #available(macOS 10.15, *) else { return foo.legacyFeature() } return foo.greatNewFeature() } Is there a way I can write unit tests which give me complete coverage of methodToTest ? All ideas I have had so

Testing codepaths for older OS versions

99封情书 提交于 2021-02-05 08:11:02
问题 If I have some library with methods like: public struct Foo { @available(macOS 10.15, *) func greatNewFeature() -> String { return "new feature" } func legacyFeature() -> String { return "legacy feature" } } Then some code that uses it: func methodToTest() -> String { let foo = Foo() guard #available(macOS 10.15, *) else { return foo.legacyFeature() } return foo.greatNewFeature() } Is there a way I can write unit tests which give me complete coverage of methodToTest ? All ideas I have had so

Angular unit tests fail, but not locally

 ̄綄美尐妖づ 提交于 2021-02-05 06:13:08
问题 After upgrading to Angular version 11, unit tests now fail on Travis CI. Locally they do succeed (even after clean install with the same node, nvm and npm versions). The error for all unit tests is the same - Failed: fn.bind is not a function TypeError: fn.bind is not a function at newTrustedFunctionForJIT (node_modules/@angular/compiler/fesm2015/compiler.js:6845:1) at JitEvaluator.evaluateCode (node_modules/@angular/compiler/fesm2015/compiler.js:6909:1) at JitEvaluator.evaluateStatements

Unit testing that items get filtered out of Observable (Jasmine/RxJS)

北战南征 提交于 2021-02-05 05:30:07
问题 I'm doing unit testing with Jasmine/Karma against an Angular service. I'd like to confirm that my service properly filters items. For example, if I have a service to get people over a certain age, it should return people over the minimum age (positive case) should NOT return people under a the minimum age (negative case) It's #2 that I'm struggling to test. The service: getPeople(minAge: number): Observable<string> { const source = Observable.from([ { name: 'Joe', age: 30 }, { name: 'Frank',

Angular - mock Promise method for Jasmine unit test

别来无恙 提交于 2021-02-04 17:08:25
问题 Method to test public onSubmit(registerData: RegisterDataModel): void { this.registrationService.registerWithEmailAndPassword(registerData).then((msg: string[]) => this.router.navigate(['/completeSignUp']).then(() => { msg.forEach(singleMessage => this.notificationService.primary(singleMessage)); })) .catch((msg) => msg.forEach(singleMessage => { this.notificationService.danger(singleMessage); })); } I want to test if router.navigate is called in my method. Now I want to mock my service

How to do Coverage exports for vscode extensions

大兔子大兔子 提交于 2021-02-04 15:26:37
问题 I have seen a lot of tutorials how to make vscode extensions. Like: https://code.visualstudio.com/docs/extensions/testing-extensions And there is many tutorials how to do coverage exports, there many ways how to do it, but I didn't seen good examples which would follow the examples from their docs and work with vscode extensions (they need the extensionHost instead of nodejs). I have all the tests written in the mocha which is bundled in the vscode as proposed by their documents. I tried to

How to do Coverage exports for vscode extensions

廉价感情. 提交于 2021-02-04 15:26:06
问题 I have seen a lot of tutorials how to make vscode extensions. Like: https://code.visualstudio.com/docs/extensions/testing-extensions And there is many tutorials how to do coverage exports, there many ways how to do it, but I didn't seen good examples which would follow the examples from their docs and work with vscode extensions (they need the extensionHost instead of nodejs). I have all the tests written in the mocha which is bundled in the vscode as proposed by their documents. I tried to

Spring Boot - Test for controller fails with 404 code

耗尽温柔 提交于 2021-02-04 14:48:09
问题 I want to write a test for controller. Here is test snippet: @RunWith(SpringRunner.class) @WebMvcTest(WeatherStationController.class) @ContextConfiguration(classes = MockConfig.class) public class WeatherStationControllerTest { @Autowired private MockMvc mockMvc; @Autowired private IStationRepository stationRepository; @Test public void shouldReturnCorrectStation() throws Exception { mockMvc.perform(get("/stations") .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); } }

Test two directory trees for equality

懵懂的女人 提交于 2021-02-04 12:01:48
问题 I am working on integration testing some part of my code that creates directory trees under SVN. This requires me to test if the directory structure and the files within are what I expect them to be. On one hand I have the expected directory tree with the files I want and on the other, an export of the files from SVN (prefer svn export over svn co to avoid the .svn noise). However, is there any library that can assert two directory trees? The last resort I have in mind is to do an iterative