My experiences on Unit Testing in the Android environment. I hope they are useful to you too.
A brief tour about how to make Android Studio run your unit tests (logical and instrumentation) and how to start creating tests for your app.
Software Engineering- Types of Testing
Unit Testing
Integration testing
System testing
Acceptance testing
Drivers and Stubs
Bottom-Up Integration
Top-down Integration
Other Approaches to Integration
Testbytes is a community of software testers who are passionate about quality and love to test. We develop an in-depth understanding of the applications under test and include software testing strategies that deliver quantifiable results.
In short, we help in building incredible software.
Software Testing Fundamentals | Basics Of Software TestingKostCare
Learn the fundamental techniques and approaches to software testing and enhanced comprehend what to test, how to test it, and in what contexts certain practices. Fundamentals of Software Testing offer an eye-opening view into this difficult task based on multiple sources of industry best practice.
Software testers are also well trained to take care of bugs that arise during the functioning of any software program. With the right quality assurance training, you will be armed with all the essentials to be qualified as a software tester. It is also essential that you enroll for a duly approved and certified training in quality assurance.
Once you acquire the necessary qa training, you will also learn the two most important skills required in software testing- advanced technical knowledge and communication.
As a proficient software tester, you should ideally possess strong written and verbal communication skills.
Good communication is important to ensure you are able to put our concepts and ideas across so that other team members understand your vision as well as understanding of the situation at hand. Even a small miscommunication can lead to serious errors in the completion of the software project.
The role of a QA professional is quite an integral one since it eases off the burden of other personnel like stakeholders, software developers as well as software managers. These people do not have to constantly worry about the quality, performance as well the errors faced in developing as well as using any new software developed.
Register For A Free DEMO:
website: www.qaonlinetrainings.com
phone: +1-609-308-7395(USA)
Email: training@qaonlinetrainings.com
MindScripts Technologies is the authorized Softwrae Testing Training institutes in Pune, providing a complete softwrae testing certification course with ISTQB certification. It provides a IBM Certified courses.
software testing is necessary to make sure the product or application is defect free, as per customer specifications. Software testing identifies fault whose removal increases the software Quality and Increases the software reliability.Testing effort is directly proportional to the complexity of the program.
Software testing is the process of evaluation a software item to detect differences between given input and expected output. Also to assess the feature of A software item. Testing assesses the quality of the product. Software testing is a process that should be done during the development process. In other words software testing is a verification and validation process.
TYPES OF TESTING
There are many types of testing like
Unit Testing
Integration Testing
Functional Testing
System Testing
Stress Testing
Performance Testing
Usability Testing
Acceptance Testing
Regression Testing
Beta Testing
Software Engineering- Types of Testing
Unit Testing
Integration testing
System testing
Acceptance testing
Drivers and Stubs
Bottom-Up Integration
Top-down Integration
Other Approaches to Integration
Testbytes is a community of software testers who are passionate about quality and love to test. We develop an in-depth understanding of the applications under test and include software testing strategies that deliver quantifiable results.
In short, we help in building incredible software.
Software Testing Fundamentals | Basics Of Software TestingKostCare
Learn the fundamental techniques and approaches to software testing and enhanced comprehend what to test, how to test it, and in what contexts certain practices. Fundamentals of Software Testing offer an eye-opening view into this difficult task based on multiple sources of industry best practice.
Software testers are also well trained to take care of bugs that arise during the functioning of any software program. With the right quality assurance training, you will be armed with all the essentials to be qualified as a software tester. It is also essential that you enroll for a duly approved and certified training in quality assurance.
Once you acquire the necessary qa training, you will also learn the two most important skills required in software testing- advanced technical knowledge and communication.
As a proficient software tester, you should ideally possess strong written and verbal communication skills.
Good communication is important to ensure you are able to put our concepts and ideas across so that other team members understand your vision as well as understanding of the situation at hand. Even a small miscommunication can lead to serious errors in the completion of the software project.
The role of a QA professional is quite an integral one since it eases off the burden of other personnel like stakeholders, software developers as well as software managers. These people do not have to constantly worry about the quality, performance as well the errors faced in developing as well as using any new software developed.
Register For A Free DEMO:
website: www.qaonlinetrainings.com
phone: +1-609-308-7395(USA)
Email: training@qaonlinetrainings.com
MindScripts Technologies is the authorized Softwrae Testing Training institutes in Pune, providing a complete softwrae testing certification course with ISTQB certification. It provides a IBM Certified courses.
software testing is necessary to make sure the product or application is defect free, as per customer specifications. Software testing identifies fault whose removal increases the software Quality and Increases the software reliability.Testing effort is directly proportional to the complexity of the program.
Software testing is the process of evaluation a software item to detect differences between given input and expected output. Also to assess the feature of A software item. Testing assesses the quality of the product. Software testing is a process that should be done during the development process. In other words software testing is a verification and validation process.
TYPES OF TESTING
There are many types of testing like
Unit Testing
Integration Testing
Functional Testing
System Testing
Stress Testing
Performance Testing
Usability Testing
Acceptance Testing
Regression Testing
Beta Testing
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
Presentation given at the ACCU 2011 Conference in Oxford, UK.
Case study of applying unit test to the DOORS codebase. Includes a quick overview of unit test & the Google Test and Mock libraries. Also 3 specific refactoring examples shown.
Breaking Dependencies to Allow Unit TestingSteven Smith
Unit testing software can be difficult, especially when the software wasn't designed to be testable. Dependencies on infrastructure concerns and software we don't control are one of the biggest contributors to testing difficulty. In this session, you'll learn the difference between unit tests and other kinds of tests, how to recognize and invert dependencies, and how to unit test your code's interactions with these dependencies without testing the infrastructure itself.
Test-Driven development; why you should never code without itJad Salhani
This is a deep dive into the TDD world where you will discover how it helps scale the development
process. The talk tackles the business side as well as the technical side of the software development
to accommodate all audiences, i.e; Why you should invest in a testing "department" for example, or
why you should always take a look at your tests when writing code.
This is a deep dive into the TDD world where you will discover how it helps scale the development process. The talk tackles the business side as well as the technical side of the software development to accommodate all audiences, i.e; Why you should invest in a testing "department" for example, or why you should always take a look at your tests when writing code.
Unit tests give developers and testers a quick way to look for logic errors in the methods of classes in Visual C#, Visual Basic, and Visual C++ projects. A unit test can be created one time and run every time that source code is changed to make sure that no bugs are introduced.
TDD is now mainstream but a lot people don't know or don't remember what is its purpose. TDD is about software design not testing or catching bug. TDD helps developers to shape and create software with "good" design, what is a "good" design is something that we will discuss in the topic.
Tell Me Quando - Implementing Feature FlagsJorge Ortiz
Change is a constant in iOS development. You must make your codebase embrace the newest features while keeping a stable app and avoiding creating a merge nightmare for you and your team. How can you do that?
In this session, I will cover what feature flags are, when to use them, how to implement them and how to enable/disable them. I will show how to make an implementation in an existing codebase by doing some live coding. As a bonus, I will show how to test different execution paths.
Key takeaways:
- Understand the benefits of using feature flags in your application
- Learn how to implement them in a real use case
- Integrate feature flags in your continuous integration
- Improve your refactoring skills
Live coding only available in video or in person :-)
Code can be found here: https://bit.ly/sh22-realm
Control your Voice like a Bene GesseritJorge Ortiz
This is my talk for the AppDevCon 2018 where I introduce attendees to the wonderful world of Voice User Interfaces. It starts with a brief introduction to Alexa Skills and Google Home Actions and how to write one of them. Then it explains the benefits of having a mobile app implemented with a good architecture.
Charla para la gente de la UPM.
Breve introducción a Go.
Presentación de la kata Gilded Rose.
Introducir pruebas unitarias en Go.
Refactorizar para triunfar.
Talk at Droidcon London 2017
Testing is a fundamental component for the success of our apps. Professionals in charge for developing Android apps are well aware of that and we are doing our best to add unit tests to our apps. But having a good test coverage is not an easy task. More so, when activities (or fragments) get in the middle.
In this talk, I shared a brief introduction about how architecture helps us to increase code coverage and provided some practical hints.
I did do some live coding to show how to use espresso and JUnit to write unit tests of an activity. The code was written in Kotlin, but the same can easily be done in Java.
The video of this talk is here: (requires free subscription)
https://skillsmatter.com/skillscasts/10534-cya-cover-your-app
The first question after people have learned about how to implement anadvanced architecture in their applications from scratch is: "How do I transform my codebase from its current state to a well architected app?" Forget about BigBang rewrites. Come and learn some strategies, tricks, and gotchas about how to do the migration to an advanced arch mobile app. Move to from Objective-C to Swift in the process and keep it functional during the whole process.
201710 Fly Me to the View - iOS Conf SGJorge Ortiz
Navigation and Dependency Inversion are two key components of an advanced architecture. This talk is about separating the user events from the semantics, injecting dependencies, memory management, live within the Storyboards and without them. Make better applications following SOLID principles.
Home Improvement: Architecture & KotlinJorge Ortiz
Two of the most relevant news from the recent Google IO were the Guide to App Architecture and the adoption of Kotlin as a first-class language. Both have a very positive impact in our applications.
In my talk I introduced and advanced architecture inspired in the Clean Architecture of Uncle Bob and I showed the impact of these two elements.
First I mentioned the components provided for integration with the lifecycle and how that saves a lot of effort to preserve view models or presenters. I briefly covered the methods that we had available until know focusing on the use of a fragment with no view that had the retained instance property set to true.
Then I covered some real scenarios explaining the improvements that Kotlin provide us with. Some examples:
- Conciseness of data classes (and limitations)
- Property observation
- Use of extensions in presentation logic
- Sealed classes for results (as an either-like type)
This is a "Code or it didn't happen" (TM) talk. ;-)
These are the slides of my talk at the Droidcon Italy 2017.
I will start with a very brief theoretical introduction to the usage of factories and the dependency inversion principle. From there on, this is a live coding session where I will start from a properly architected app and show how it helps to do things such as reusing an existing use case in another view controller, or using a different backend, in case we are forced to do so (Any bitter memories?). I will also cover briefly how this architecture helps with testability. The goal is to prove that the benefits of a good architecture are very immediate and valuable.
Come enjoy and spread the message within your team!
We usually hear about intangible or difficult to measure benefits of implementing a good architecture. I would like to prove to you that the benefits are far more mundane. In this talk I will showcase practical, real world examples of how a good architecture for your application makes your life easier. Using my interpretation of the Clean Architecture for Android in Kotlin, I will show how it helps to do things such as reusing an existing use case in another view controller, or using a different backend, in case we are forced to do so. I will also cover briefly how this architecture helps with testability.
These are the slides of my talk at iOSCon 2017: https://skillsmatter.com/skillscasts/9549-architecting-alive-apps
Our apps are ever more alive. They interact with the rest of the world talking to backends and receiving notifications from them. They get their input from us and from other sensors. They are even aware of the location of the device they run in, or its position. But, in our IoT world, they may also detect presence in a room, get the temperature of it, or change the color of its lights.
Sadly enough, many of the apps available today with those capabilities have some architectural limitations:
Many of them are written in a way that is really dependent on a specific hardware.
Some restrict their use cases to whatever is provided by the hardware devices.
And almost all of them expect having a connection with the real device as the only way to test if they work properly.
However, we can also use an advanced architecture, like the Clean Architecture, to create a beautiful, scalable, testable, and robust application. Join Jorge and he will share with you how you can do it!
This is a "Code or it didn't happen" (TM) talk.
The 3h workshop version of the 3d Advanced Architectures training (http://canonicalexamples.com/courses_ios/#iOSArch). I have delivered this one or the Android counterpart in more than 20 cities in Europe and America. This is version that I shared in Cluj Napoca.
The 3h workshop version of the 3d Advanced Architectures training (http://canonicalexamples.com/courses_android/#androidArch). I have delivered this one or the iOS counterpart in more than 20 cities of Europe and America. This is the latest version that shared in Minsk.
The 3h workshop version of the Hands on Implementation of Clean Architecture in iOS. I have delivered this one or the Android counterpart in more that 20 cities of Europe and America.
Everybody involved in a mid size project or bigger is concerned about architecture. We have all been told that a good architecture can help us to have a more agile, robust, and easier to work with application, but it is not always clear how nor the architecture everybody else is talking about. By establishing parallelisms with Andy Weir's story, The Martian, I will go through the most relevant problems we usually find, explain how a well thought out architecture can be valuable to us, and share some code that implements it.
I use Swift in all of the code examples, because, in my opinion, it is very well suited for implementing those advanced architectures. If you care:
- The talk includes only minor spoilers
- No, it isn't about MVC, but beyond that
Why the Dark Side should use Swift and a SOLID ArchitectureJorge Ortiz
Everybody involved in a mid size project or bigger is concerned about architecture. We have all been told that a good architecture can help us to have a more agile, robust, and easier to work with application, but it is not always clear how nor the architecture everybody else is talking about. By establishing parallelisms with the very well known problems of the Death Stars and the Starkiller Base, I go through the most relevant problems, explain how a well thought out architecture can be valuable to us, and share some code that implements it. The talk includes only minor spoilers, it will focus on more than MVC. It uses Swift in all of the code examples, because it is very well suited to implement those advanced architectures.
Take away concepts:
Architectural concepts for mobile applications
How to use some common design patterns
How to improve the testability of your code
Take advantage of Swift features
We usually hear about intangible or difficult to measure benefits of implementing a good architecture. I would like to prove to you that the benefits are far more mundane. In this talk I will showcase practical, real world examples of how a good architecture for your application makes your life easier. Using my interpretation of the Clean Architecture for iOS in Swift, I will show how it helps to do things such as reusing an existing use case in another view controller, or using a different backend, in case we are forced to do so. I will also cover briefly how this architecture helps with testability.
This are the slides for the talk that I made at Codemotion 2015.
Swift had provided developers with new features of the most modern languages combined with a simple and elegant syntax. In this presentation I explore what an advanced architecture is and its benefits, how design patterns help us in an advanced architecture, and how to implement those patterns in Swift, taking advantage of Swift 2.x new features.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
Let's dive deeper into the world of ODC! Ricardo Alves (OutSystems) will join us to tell all about the new Data Fabric. After that, Sezen de Bruijn (OutSystems) will get into the details on how to best design a sturdy architecture within ODC.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
7. #7SUnitTest
Unit Tests
★ Prove correctness of different aspects of the
public interface.
• Prove instead of intuition
• Define contract and assumptions
• Document the code
• Easier refactoring or change
★ Reusable code = code + tests
8. #7SUnitTest
Use Unit Testing
Incrementally
★ You don’t have to write every unit test
★ Start with the classes that take care of the
logic
• If mixed apply SOLID
★ The easier entry point are bugs
13. #7SUnitTest
Good & Bad News
★ Most things are already available in Android Studio
★ Projects are created with
• test package
• ApplicationTest class
★ It requires some tweaking
★ Google docs are for Eclipse
• modules instead of projects
• different UI…
20. public class TaskTests extends TestCase {
final static String TASK_NAME = "First task";
final static String TASK_DONE_STRING = "First task:
Done";
final static String TASK_NOT_DONE_STRING = "First
task: NOT done";
Task mTask;
@Override
public void setUp() throws Exception { super.setUp();
mTask = new Task(); }
@Override
public void tearDown() throws Exception
{ super.tearDown();
mTask = null; }
public void testDoneStatusIsDisplayedProperly()
throws Exception {
mTask.setName(TASK_NAME);
mTask.setDone(true);
String taskString = mTask.toString();
assertEquals("String must be "taskname: Done"",
TASK_DONE_STRING, taskString);
}
public void testNotDoneStatusIsDisplayedProperly()
throws Exception {
mTask.setName(TASK_NAME);
mTask.setDone(false);
assertEquals("String must be "taskname: NOT done
"", TASK_NOT_DONE_STRING, mTask.toString()); } }
Example
public class Task {
private String mName;
private Boolean mDone;
public String getName() { return
mName; }
public void setName(String name)
{ mName = name; }
}
public Boolean getDone() { return
mDone; }
public void setDone(Boolean done) {
mDone = done;
}
@Override
public String toString() {
return mName + ": " +
(mDone?"Done":"NOT done");
}
}
21. public class ModelAndLogicTestSuite
extends TestSuite {
public static Test suite() {
return new
TestSuiteBuilder(ModelAndLogicTestS
uite.class)
.includePackages(“c
om.powwau.app.interactor”,
“com.powwau.app.data”)
.build();
}
public ModelAndLogicTestSuite()
{
super();
}
}
Running more than one
TestCase
public class FullTestSuite
extends TestSuite {
public static Test suite() {
return new
TestSuiteBuilder(FullTestSuite.cl
ass)
.includeAllPackag
esUnderHere()
.build();
}
public FullTestSuite() {
super();
}
}
22. Instrumentation Tests
public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {
Activity mActivity;
public MainActivityUnitTest() {
super(MainActivity.class);
}
@Override
public void setUp() throws Exception {
super.setUp();
mActivity = getActivity();
}
public void testHelloIsDisplayed() throws Exception {
onView(withText(“Hello world!")).check(ViewAssertions.matches(isDisplayed()));
}
public void testSalutationChangesWithButtonClick() throws Exception {
onView(withText("Touch Me")).perform(click());
onView(withText("Bye bye,
Moon!”)).check(ViewAssertions.matches(isDisplayed()));
}
}
26. #7SUnitTest
Dependency Injection
★ Control behavior of the dependencies
• Constructor
• Method overwriting
• Property injection:Lazy instantiation
★ Or use a DI framework: Dagger 2
29. DataRepo dataRepoMock = mock(DataRepo.class);
when(dataRepoMock.existsObjWithId(23)).thenReturn(
true);
verify(dataRepoMock).deleteObjWithId(23);
Simulating and Testing
Behavior
★ Stubs & Mocks
• Both are fake objects
• Stubs provide desired responses to the SUT
• Mocks also expect certain behaviors
37. #7SUnitTest
Use JUnit 4
★ Don’t extend TestCase
★ Don’t start with test (@Test instead)
★ @Before & @After instead of setUp and
tearDown. Also for the class
★ @ignore
★ Exceptions & timeouts (@Test params)
★ @Theory & @DataPoints