-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature run test under different package #1834
base: development
Are you sure you want to change the base?
Conversation
for instrumentation tests
to define the in-memory dabatabase for instrumentation tests Removing CustomTestRunner instead using IDatabaseHolderProviderStrategy Removing EyeSeeTeaTestingApplication Updating falling tests
To fix the issue, I included the Dbflow annotation processor as a library dependency and I updated it in a such a way that it generates an in-memory database. Then I updated the EyeSeeTeaApplication class using the strategy pattern to allow switching between the in-memory database for instrumentation and on disk database. |
@Amejia481 the PR says 99 files modified. I would like to be sure where this branch was created, to be sure there's not a git problem here. IMO, there are 2 places where this branch could be created: development or v1.1_connect. If you created in v1.1_connect, you should merge the branch against v1.1_connect, and likewise for development. Can you please have a look and tell me why this huge files change? |
Sure, I created from the development branch, there are so many file changes because, I added Dbflow annotation processor as a module dependency, this way I modify its code. |
Hi @ifoche, Finally, we got rid of the staging build type 😛 Now every time, that we run an instrumentation test(doesn't matter which variant), it's using an in-memory database. Also, I added a JUnit Rule for keeping the state of the in-memory DB separated from each This test Rules don't allow to share DB state between public class MyTestShould {
@Rule
public InMemoryDBFlowDataBase mInMemoryDBFlowDataBase = new InMemoryDBFlowDataBase();
@Test
public void test1() {
QuestionDB question1 = new QuestionDB();
question1.save(); //After this line id_question
// It's going to be equals to 1
}
@Test
public void test2() {
QuestionDB question2 = new QuestionDB();
question2.save(); //After this line id_question
// it's still equals to 1 not 2
// The InMemoryDBFlowDataBase cleans up for you.
}
} Note: For the dbflow annotation processor submodule to work, it must be checkout under |
@@ -44,9 +38,11 @@ | |||
|
|||
private final Program program = new Program("T_TZ", "low6qUS2wc9"); | |||
|
|||
@Rule | |||
public InMemoryDBFlowDataBase mInMemoryDBFlowDataBase = new InMemoryDBFlowDataBase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example of using the JUnit rule that I mentioned in the PR.
@Before | ||
public void setUp() throws Exception { | ||
PopulateDB.wipeDataBase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, I can delete this line, because the rule is keeping the state of the DB separated, between @Test
…base, and added the before method on constructor
…ormal app preferences, database, etc, the context only the test
📌 References
@xurxodev I merged development, tested the feature and updated the failing test. Some notes: We should create a solution to avoid it. Now: I think the problem only happens when we use InstrumentationRegistry.getTargetContext(is a real app context) instead of InstrumentationRegistry.getContext()(is a test context). The problem is with the getString(string id) methods get an exception when we use the test context, the get String methods only work with getTarget context. We should separate the context used by shared preference load / save, and the context used to get translations. At this moment this is solved with this steps: First step: the test gets the app´s preferences one by one and saves it in memory. Second step: The test modifies that preferences to be used by test, or add others. Third step: when the test is finished, it restores the app preferences saving one by one the loaded preferences. 💥 How can it be tested?Before test this branch: If you will test this branch before merging the v1.3_connect changes: To make this branch work you will modify the dynamictabadapter. and change the requireQuestionOptionValidations method to: return true; That problem is fixed in v1.3 To test this branch: Use case 1: Use case 2: 💾 Requires DB migration?
🎨 UI changes?
|
@idelcano I have created an issue to merge connect 1.3 in development and when these issues is solved then I will review this Pull Request again |
close #1747