How to test SingleLiveEvent variable?2019 Community Moderator ElectionHow do I test a private function or a class that has private methods, fields or inner classes?Unit Testing C CodeIs Unit Testing worth the effort?How do save an Android Activity state using save instance state?What is Unit test, Integration Test, Smoke test, Regression Test?Why is the Android emulator so slow? How can we speed up the Android emulator?How to make mock to void methods with mockitoWriting unit tests in Python: How do I start?How do I fix android.os.NetworkOnMainThreadException?Making a private method public to unit test it…good idea?
How to kill a localhost:8080
How can I handle a player who pre-plans arguments about my rulings on RAW?
Create chunks from an array
Can a Trickery Domain cleric cast a spell through the Invoke Duplicity clone while inside a Forcecage?
Why won't the strings command stop?
Would the melodic leap of the opening phrase of Mozart's K545 be considered dissonant?
Why are banks allowed to resell mortgages?
Draw bounding region by list of points
Is there a math equivalent to the conditional ternary operator?
GPL code private and stolen
Split a number into equal parts given the number of parts
Why is it "take a leak?"
Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?
Where is this quote about overcoming the impossible said in "Interstellar"?
If there are any 3nion, 5nion, 7nion, 9nion, 10nion, etc.
3.5% Interest Student Loan or use all of my savings on Tuition?
Misplaced tyre lever - alternatives?
Can an earth elemental drown/bury its opponent underground using earth glide?
What could be a means to defeat a childrens’ nightmare?
Why doesn't "adolescent" take any articles in "listen to adolescent agonising"?
Plagiarism of code by other PhD student
Caulking a corner instead of taping with joint compound?
Formatting a table to look nice
In which way proportional valves are controlled solely by current?
How to test SingleLiveEvent variable?
2019 Community Moderator ElectionHow do I test a private function or a class that has private methods, fields or inner classes?Unit Testing C CodeIs Unit Testing worth the effort?How do save an Android Activity state using save instance state?What is Unit test, Integration Test, Smoke test, Regression Test?Why is the Android emulator so slow? How can we speed up the Android emulator?How to make mock to void methods with mockitoWriting unit tests in Python: How do I start?How do I fix android.os.NetworkOnMainThreadException?Making a private method public to unit test it…good idea?
I have a SingleLiveEvent<Void>
variable. On getting response from api I am making it post. My callback is called and a popup is shown.
My question is how will I write a test case for checking, is my popup shown or not.
Live Event:
private SingleLiveEvent<Void> onAccountOverDrawn = new SingleLiveEvent<>();
On success response I am calling:
onAccountOverDrawn.post();
In my fragment I am registering it as
viewModel.getOnAccountOverDrawn().observe(this, aVoid -> onAccountOverDrawn());
and in onAccountOverDrawn()
I am just showing a popup.
So how will I write a test case for this scenario?
Current test case:
@Test
public void updateApplicationStatus_AccountOverdrawn()
viewModel.updateApplicationStatus("AMOUNT_PENDING");
assertNotNull(viewModel.getOnAccountOverDrawn()); //this line is of no use. Need to change this.
android unit-testing testing
add a comment |
I have a SingleLiveEvent<Void>
variable. On getting response from api I am making it post. My callback is called and a popup is shown.
My question is how will I write a test case for checking, is my popup shown or not.
Live Event:
private SingleLiveEvent<Void> onAccountOverDrawn = new SingleLiveEvent<>();
On success response I am calling:
onAccountOverDrawn.post();
In my fragment I am registering it as
viewModel.getOnAccountOverDrawn().observe(this, aVoid -> onAccountOverDrawn());
and in onAccountOverDrawn()
I am just showing a popup.
So how will I write a test case for this scenario?
Current test case:
@Test
public void updateApplicationStatus_AccountOverdrawn()
viewModel.updateApplicationStatus("AMOUNT_PENDING");
assertNotNull(viewModel.getOnAccountOverDrawn()); //this line is of no use. Need to change this.
android unit-testing testing
so you want to test if the SingleLiveEvent has been observed or not?
– Muhammad Younas
12 hours ago
add a comment |
I have a SingleLiveEvent<Void>
variable. On getting response from api I am making it post. My callback is called and a popup is shown.
My question is how will I write a test case for checking, is my popup shown or not.
Live Event:
private SingleLiveEvent<Void> onAccountOverDrawn = new SingleLiveEvent<>();
On success response I am calling:
onAccountOverDrawn.post();
In my fragment I am registering it as
viewModel.getOnAccountOverDrawn().observe(this, aVoid -> onAccountOverDrawn());
and in onAccountOverDrawn()
I am just showing a popup.
So how will I write a test case for this scenario?
Current test case:
@Test
public void updateApplicationStatus_AccountOverdrawn()
viewModel.updateApplicationStatus("AMOUNT_PENDING");
assertNotNull(viewModel.getOnAccountOverDrawn()); //this line is of no use. Need to change this.
android unit-testing testing
I have a SingleLiveEvent<Void>
variable. On getting response from api I am making it post. My callback is called and a popup is shown.
My question is how will I write a test case for checking, is my popup shown or not.
Live Event:
private SingleLiveEvent<Void> onAccountOverDrawn = new SingleLiveEvent<>();
On success response I am calling:
onAccountOverDrawn.post();
In my fragment I am registering it as
viewModel.getOnAccountOverDrawn().observe(this, aVoid -> onAccountOverDrawn());
and in onAccountOverDrawn()
I am just showing a popup.
So how will I write a test case for this scenario?
Current test case:
@Test
public void updateApplicationStatus_AccountOverdrawn()
viewModel.updateApplicationStatus("AMOUNT_PENDING");
assertNotNull(viewModel.getOnAccountOverDrawn()); //this line is of no use. Need to change this.
android unit-testing testing
android unit-testing testing
edited 13 hours ago
Fantômas
32.7k156390
32.7k156390
asked 14 hours ago
Ashwani KumarAshwani Kumar
7501022
7501022
so you want to test if the SingleLiveEvent has been observed or not?
– Muhammad Younas
12 hours ago
add a comment |
so you want to test if the SingleLiveEvent has been observed or not?
– Muhammad Younas
12 hours ago
so you want to test if the SingleLiveEvent has been observed or not?
– Muhammad Younas
12 hours ago
so you want to test if the SingleLiveEvent has been observed or not?
– Muhammad Younas
12 hours ago
add a comment |
1 Answer
1
active
oldest
votes
If you want to test whether there was a pop up or not, you can use Robolectric.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55021261%2fhow-to-test-singleliveeventvoid-variable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want to test whether there was a pop up or not, you can use Robolectric.
add a comment |
If you want to test whether there was a pop up or not, you can use Robolectric.
add a comment |
If you want to test whether there was a pop up or not, you can use Robolectric.
If you want to test whether there was a pop up or not, you can use Robolectric.
answered 13 hours ago
Paramvir SinghParamvir Singh
1,77111619
1,77111619
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55021261%2fhow-to-test-singleliveeventvoid-variable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
so you want to test if the SingleLiveEvent has been observed or not?
– Muhammad Younas
12 hours ago