unit-testing

Running android unit tests from the command line?

Deadly 提交于 2021-02-05 20:25:02
问题 I'm trying to run unit tests on the android platform in accordance with tutorial. Say, for example, I want to run tests for Email application. I open /apps/Email/tests/AndroidManifest.xml file, look for the <manifest> element, and look at the package attribute, which is com.android.email.tests , and in the <instrumentation> element I look at the android:name attribute, which is android.test.InstrumentationTestRunner . Now I open the console, and run $ . build/envsetup.sh $ lunch 1 $ adb shell

Do you write your unit tests before or after coding a piece of functionality? [closed]

偶尔善良 提交于 2021-02-05 20:22:37
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . I was wondering when most people wrote their unit tests, if at all. I usually write tests after writing my initial code to make sure

How do I install NUnit 3 console on Windows and run tests?

拜拜、爱过 提交于 2021-02-05 20:18:36
问题 I want to run tests from a console like this (being in any directory, the DLL file can be for a different .NET version): $ nunit3-console test.dll I googled a lot, but can't find how to set up this. The official tutorial has nothing useful and is complete zero. Following it gets me nowhere: https://github.com/nunit/docs/wiki/Installation 回答1: It is hard to find, because there is a lot of outdated documentation, either for NUnit2 or NUnit3. Steps: Official NUnit3 console installers are here:

How do I install NUnit 3 console on Windows and run tests?

喜你入骨 提交于 2021-02-05 20:17:50
问题 I want to run tests from a console like this (being in any directory, the DLL file can be for a different .NET version): $ nunit3-console test.dll I googled a lot, but can't find how to set up this. The official tutorial has nothing useful and is complete zero. Following it gets me nowhere: https://github.com/nunit/docs/wiki/Installation 回答1: It is hard to find, because there is a lot of outdated documentation, either for NUnit2 or NUnit3. Steps: Official NUnit3 console installers are here:

How do you mock and test the same function in C/C++ with FFF and Google Test?

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-05 11:35:13
问题 I am exploring TDD (Test Driven Development) to test the code that I am writing in C and C++. I have chosen to use Google Test as the unit test framework. I have chosen to use FFF as the mocking framework. I have written a few tests and run them and it works great. But I have come across an issue that I have not been able to find any reference to online and I was hoping the community could help me (and this would help others as well). The issue I have is that I would like to write a test for

How to test Comparator for JUnit test?

佐手、 提交于 2021-02-05 09:28:28
问题 I need to test the compare() method and i am confused on how. Can I see how to do this? public class MemberComparator implements Comparator<Member> { private final String clientId; public MemberComparator(String clientId) { this.clientId = clientId; } @Override public int compare(Member m1, Member m2) { if (m1.getClientId().startsWith(clientId)) { return m2.getClientId().startsWith(clientId) ? m1.getClientId().compareTo(m2.getClientId()) : -1; } else { return m2.getClientId().startsWith

How to test Comparator for JUnit test?

隐身守侯 提交于 2021-02-05 09:27:17
问题 I need to test the compare() method and i am confused on how. Can I see how to do this? public class MemberComparator implements Comparator<Member> { private final String clientId; public MemberComparator(String clientId) { this.clientId = clientId; } @Override public int compare(Member m1, Member m2) { if (m1.getClientId().startsWith(clientId)) { return m2.getClientId().startsWith(clientId) ? m1.getClientId().compareTo(m2.getClientId()) : -1; } else { return m2.getClientId().startsWith

How to test Coroutine with ViewModel in Kotlin?

不问归期 提交于 2021-02-05 09:16:10
问题 I could not test my method it feels it doesn't reach inside uiScope.launch block and I have posted my viewModel method which I am trying to test and fetchActivationCodeWithDuration is suspend function. and in the bottom is my test class and I get this message java.lang.AssertionError: Expected :ActivationCode(code=111111, expires=2019-05-23T10:03:50.614Z, duration=815960) Actual :null protected val uiScope = CoroutineScope(Dispatchers.Main + viewModelJob) fun loadActivationCode() { uiScope

How to test Coroutine with ViewModel in Kotlin?

浪尽此生 提交于 2021-02-05 09:16:02
问题 I could not test my method it feels it doesn't reach inside uiScope.launch block and I have posted my viewModel method which I am trying to test and fetchActivationCodeWithDuration is suspend function. and in the bottom is my test class and I get this message java.lang.AssertionError: Expected :ActivationCode(code=111111, expires=2019-05-23T10:03:50.614Z, duration=815960) Actual :null protected val uiScope = CoroutineScope(Dispatchers.Main + viewModelJob) fun loadActivationCode() { uiScope

Question about Karate test case for POST method

◇◆丶佛笑我妖孽 提交于 2021-02-05 08:16:41
问题 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"