The document provides best practices for writing unit tests, including mocking external services, writing focused tests for individual code units, avoiding unnecessary assertions, using annotations to test exceptions, and refactoring code if tests become too complex. Good practices like giving tests descriptive names and adding new tests for each found bug are also recommended. The document emphasizes that tests should serve as documentation and prevent regressions.
The presentation contains a definition and survey of the benefits of Unit Testing, and a little coding example to get the feeling of Unit Testing using JUnit, EasyMock and XMLUnit.
The presentation contains a definition and survey of the benefits of Unit Testing, and a little coding example to get the feeling of Unit Testing using JUnit, EasyMock and XMLUnit.
Unit testing has entered the main stream. It is generally considered best practice to have a high level of unit test code coverage, and to ideally write tests before the code, via Test Driven Development.
However, some code is just plain difficult to test. The cost of effort of adding the tests may seem to outweigh the benefits. In this session, we will do a quick review of the benefits of unit tests, but focus on how to test tricky code, such as that static and private methods, and legacy code in general.
Examples are in Java, but the principals are language agnostic.
Unit Testing 101 presented at ESRI Developer Summit, March 24th, 2009. This talk reviews the key concepts of unit testing, the technologies used by DTSAgile in out development projects.
Integrate the Microsoft Unit Testing Framework into your Visual Studio 2010 projects. Learn the fundamentals of the Microsoft.VisualStudio.TestTools.UnitTesting namespace. Explore the tools for running and debugging your unit tests. Discuss general best practices for writing unit tests. Examples will be presented in C#.
A short presentation slide deck I gave to interns we have this summer of 2019 on (unit) testing in software development. This is not a code-centric slide deck and just looking at the slides loses some context without being there in person, or having discussions, etc.
A brief introduction about the art of unit test, how to test a class, mock a collaborator and use a fake database. TDD is introduced. Code for exercises is available on github along with a detailed explanation. Examples and exercises are written in Java.
An introduction to unit testing using Visual Studio, C#, xUnit.net, and Moq. What it is, what is isn't, why we don't do it, how to design for testability, what to test, test driven development, unit testing frameworks, mocking libraries, how to get started.
Unit testing has entered the main stream. It is generally considered best practice to have a high level of unit test code coverage, and to ideally write tests before the code, via Test Driven Development.
However, some code is just plain difficult to test. The cost of effort of adding the tests may seem to outweigh the benefits. In this session, we will do a quick review of the benefits of unit tests, but focus on how to test tricky code, such as that static and private methods, and legacy code in general.
Examples are in Java, but the principals are language agnostic.
Unit Testing 101 presented at ESRI Developer Summit, March 24th, 2009. This talk reviews the key concepts of unit testing, the technologies used by DTSAgile in out development projects.
Integrate the Microsoft Unit Testing Framework into your Visual Studio 2010 projects. Learn the fundamentals of the Microsoft.VisualStudio.TestTools.UnitTesting namespace. Explore the tools for running and debugging your unit tests. Discuss general best practices for writing unit tests. Examples will be presented in C#.
A short presentation slide deck I gave to interns we have this summer of 2019 on (unit) testing in software development. This is not a code-centric slide deck and just looking at the slides loses some context without being there in person, or having discussions, etc.
A brief introduction about the art of unit test, how to test a class, mock a collaborator and use a fake database. TDD is introduced. Code for exercises is available on github along with a detailed explanation. Examples and exercises are written in Java.
An introduction to unit testing using Visual Studio, C#, xUnit.net, and Moq. What it is, what is isn't, why we don't do it, how to design for testability, what to test, test driven development, unit testing frameworks, mocking libraries, how to get started.
Slides from my Confitura 2012 presentation. The issues discussed during the talk will be described in my new (free!) ebook - see https://github.com/tomekkaczanowski/bad-tests-good-tests
Mutation Testing: Start Hunting The BugsAri Waller
By Sven Ruppert: JUnit is a well-known tool for java developers in the area of TDD. Here it has become accepted, that CodeCoverage can be measured. In this case we distinguish between coverage on the level of classes, methods and rows. The goal is to get the CodeCoverage as high as possible on the row level, but not higher than necessary.
What exactly does it mean? A CodeCoverage of appr. 75% on the row level is very good and can already provide a basis. But what does this figure say?
Benoit Baudry, Professor at KTH University, offered this presentation of STAMP software testing tools Descartes and DSpot, to Orange DevOps teams, using a remote webinar on October 2, 2019.
Testing, Performance Analysis, and jQuery 1.4jeresig
This is the talk that I gave at JSConf.eu 2009, then modified slightly and given again at the December Bayjax meetup (the parts on jQuery and HTML 5 in IE were added).
Unit Testing Front End JavaScript
with Yuri Takhteyev
Presented on September 18 2014 at
FITC's Web Unleashed Toronto 2014 Conference
More info at www.fitc.ca
Building complex software application can be made much easier with unit testing – a fact well established in back-end work but often overlooked on the front-end. Yuri Takhteyev will look at some of the tools and techniques for unit testing front end code, focusing on Mocha and Karma. Most of the examples will draw on AngularJS but the main ideas are applicable to other frameworks as well.
OBJECTIVE
Learn how to write unit tests for front-end code.
TARGET AUDIENCE
Front-end JavaScript developers not currently using unit testing or those experiencing difficulties with unit testing.
ASSUMED AUDIENCE KNOWLEDGE
Intermediate front-end JavaScript, no prior experience with front-end unit testing
FIVE THINGS AUDIENCE MEMBERS WILL LEARN
How unit testing benefits the developer
How to structure applications to make them testable
How to use Mocha and Karma in unit testing
How to mock dependencies (and why)
How to handle asynchronous code
Unit testing patterns for concurrent codeDror Helper
Getting started with unit testing is not hard, the only problem is that most programs are more than a simple calculator with two parameters and a returns value that is easy to verify.
Writing unit tests for multi-threaded code is harder still.
Over the years I discovered useful patterns that helped me to test multi-threaded and asynchronous code and enabled the creation of deterministic, simple and robust unit tests.
Come learn how to test code that uses concurrency and parallelism – so that the excuses of not writing unit tests for such code would become as obsolete as a single core processors.
The Top Benefits of Magnolia CMS’s Inspirational Open Suite IdeologyTricode (part of Dept)
In an increasingly agile world, Magnolia’s Open Suite approach enables companies to maximize choice and future-proof their digital investments. This is possible thanks to CMS's open architecture, which allows organizations to connect existing and future tools into an integrated platform for digital marketing, commerce and services.
QA professionals in an Agile Environment are required to be fluid and agile themselves, discarding previous paradigms and focusing on techniques to optimize a new strategy to testing. Having a tester in your team is not a luxury, but a necessity to raise the quality of the product. So why are testers the excess in the eyes of the team and what do testers have to say in their defense? Stay tuned for this Star Wars™️ themed presentation.
Mobile Sensor Networks based on Smartphone devices and Web ServicesTricode (part of Dept)
We are all witnesses that the modern smartphones rapidly have become very powerful computing platforms and maybe the most significant and respectable communication devices in our lives. The constant technological progress undoubtedly raises the question related to mobile sensing researches through the analysis of modern smartphones that come with growing set of advanced embedded sensors. Modern smartphones, as sophisticated computing platforms with complex sensor capabilities have opened the horizon for challenges associated with smartphone sensor networks and development of new high sophisticated mobile applications. This presentation addresses the actual emerge trend that allows very coupled correlation between the concepts of “The Mobile Phone as a Sensor” and “Human as a Sensor".
How can we as developers make our communication with the (usually non-tech savvy) client easier? How to understand their demands and communicate them to the rest of our team? How can those clients be satisfied with the level of service, without us having to spend sleepless nights hacking away at various issues? The answer to all this and more awaits here.
Presented by Andrej Gasteovski at SkopjeTechMeetup 8.
Building a modern web (or mobile) application requires a lot of tools, frameworks and techniques. Java Hipster a.k.a. JHipster is a free and open-source Yeoman generator that can develop a modern web application using Spring Boot and AngularJS with tons of options in just a few clicks. We will see the full stack that JHipster is using, what can be done, pros and cons and a simple application generated by JHipster.
Presented by Nikola Sudijovski at SkopjeTechMeetup 8.
Looking back at all the progress humanity has made through the last few centuries, it's perfectly natural to feel a little bit moved by the power of human ingenuity and our thrive for constant improvement. It's natural, but also (for the most part) wrong. If we really looked into the history of our technological development, we'd notice а pretty intriguing pattern, often intentionally left unmentioned. Well, that is, until now.
Nearshoring is een grote kans om uw business uit te breiden. Toch zitten er risico's aan, die je zult moeten vermijden. U vindt de belangrijkste 4 risco's overzichtelijk in deze presentatie
Presented by Martin Mihajlov at SkopjeTechMeetup 7.
Almost 50% of the world population is online. Constantly. Half of the population has joined a virtual world that is replacing more aspects of our daily life. Can we be addicted to the Internet in the same way we are addicted to drugs? Alcohol? Sex? Or is this a reflection of something more grandeur?
Presentation from Goran Velkoski & Ivana Nizamovska on SkopjeTechMeetup 7.
Every child should have the opportunity to learn computer science. It helps nurture problem-solving skills, logic and creativity. By starting early, kids will have the capability to shape the future. This are the main reasons why Goran and Ivana decided to organize “Kids can Code”, an introduction to computer science designed for 7-9 year olds to discover coding and show them that anybody can learn the basics.
Presented by Nikola Vasilev on SkopjeTechMeetup 7.
Representational state transfer (REST) can be thought of as the language of the Internet. Now with cloud usage on the rise, REST is a logical choice for building APIs that allow end users to connect and interact with cloud services. This talk will deliver more insight into the challenges on building and maintaining good and clean RESTful APIs.
SkopjeTechMeetup is an initiative by Tricode for supporting and strengthening the Macedonian IT community. The meetups have the goal of establishing a networking platform for the IT crowd where they can share their know-how, best practices, as well as mutual inspiration.
The 6th STM installment took place at Piazza Liberta, Skopje last Thursday, the 29th of September. This meetup hosted 3 seasoned speakers, each accomplished in their own way.
Here's the presentation of Igor Trajkovski.
In recent years, Deep Learning has become a dominant Machine Learning tool for a wide variety of domains. In this lecture Trajkovski will present one of its biggest successes, Computer Vision, where the performance in problems such object recognition has been improved dramatically.
SkopjeTechMeetup is an initiative by Tricode for supporting and strengthening the Macedonian IT community. The meetups have the goal of establishing a networking platform for the IT crowd where they can share their know-how, best practices, as well as mutual inspiration.
The 6th STM installment took place at Piazza Liberta, Skopje last Thursday, the 29th of September. This meetup hosted 3 seasoned speakers, each accomplished in their own way.
Here's the presentation of Ermal Sadiku.
In a world where society is moved by science and technology more than anything, scientists and engineers have the power to change the world for better or worse. How should we look at and understand this in order to make the right choices?
SkopjeTechMeetup is an initiative by Tricode for supporting and strengthening the Macedonian IT community. The meetups have the goal of establishing a networking platform for the IT crowd where they can share their know-how, best practices, as well as mutual inspiration.
The 6th STM installment took place at Piazza Liberta, Skopje last Thursday, the 29th of September. This meetup hosted 3 seasoned speakers, each accomplished in their own way.
Here's the presentation of Lazo Apostolovski.
The Microservices Architecture pattern is getting a lot of attention lately, even at the beginning of its adoption lifecycle. It has significant benefits when it comes to enabling agile development and delivering complex enterprise applications. Adopting Microservices can be a tricky and dangerous process. Making bad decisions early can lead to serious complications, expences and maybe even failure.
Each interaction with your customer, small or large, has a direct impact on the customer's experience and influences his perception of your brand and company. Since 2013, Tricode entered into a partnership with Magnolia CMS for its implementation in the Benelux. Tricode invests significantly in the formation and composition of Magnolia development teams with well-trained professionals. With Magnolia CMS, we offer a user-friendly, adaptable and expandable solution, ideal for creating, managing and editing the content your users interact with across multiple digital channels. But you don’t have to just take our word for it, what follows are testimonials from some of the dozens of satisfied Magnolia CMS clients.
Eigenlijk is vragen naar uw super power vragen naar de bekende weg. Wij weten al waar jouw kracht ligt. Jij bent een kei in het bedenken van creatieve concepten, campagnes, websites en apps.
Ontstaat er bij jou ook kortsluiting als je wél de projecten hebt maar niet de mensen? De creatie is er, maar de development om jouw ideeën technisch te realiseren ontbreekt. Laat dit nou juist onze specialisatie zijn! Wij zijn goed in het vertalen van creatieve concepten in technische oplossingen. Nerds, zo zou je ons ook wel kunnen noemen. Of softwarespecialisten die blij worden van jouw IT-vraagstukken. Hoe ingewikkelder, hoe beter.
Wij van Tricode laden jouw team graag op met onze development power. Samen helpen we je bij het technisch realiseren van jouw creatieve concepten. Met onze mensen uit Veenendaal maar ook met onze Macedonische collega’s: goed opgeleide developers, die uitstekend Engels spreken en een mentaliteit hebben die matcht bij onze Hollandse werkethos. We nemen je het werk graag uit handen op projectbasis, maar kunnen jouw team ook (tijdelijk) empoweren met één van onze developers.
Adobe Experience Manager 6.2 has been released and it features quite a few changes and improvements.
Here's a brief overview of what you can look forward to from this update.
Nearshoring, waarom kiezen veel bedrijven voor deze optie om werk uit te besteden? Lees de top 10 nearshoring trends in de ICT markt in deze presentatie
Based in the Netherlands and Macedonia we can tell you all about the ins and outs of Magnolia CMS. We think along and are able to implement and configure Magnolia CMS with a minimum of costs and a maximum of benefit for your organisation.
Tricode is not the kind of organisation that implements Magnolia CMS and let you struggle with updates, new possibilities and so on. We take care of the full application lifecycle management if you appreciate.
We chose to be Magnolia partner because of the superior benefits it brings our customers, but also because Magnolia gives partners the possibility to build extra features.
This presentation gives you an insight of the advantages using Adobe Experience Manager Mobile for creating and managing Mobile apps. AEM Mobile reduces the time to market of mobile apps with 50-70% compared to most other App development andmanagement tools.
‘‘Powering your digital marketing’ - At Tricode, this is synonymous with a perfectly balanced process. Adapted and honed on the basis of years of experience. The crux of our approach? Tricode's intelligent software factory. We support you - from request to solution - in a single process.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
Quality defects in TMT Bars, Possible causes and Potential Solutions.PrashantGoswami42
Maintaining high-quality standards in the production of TMT bars is crucial for ensuring structural integrity in construction. Addressing common defects through careful monitoring, standardized processes, and advanced technology can significantly improve the quality of TMT bars. Continuous training and adherence to quality control measures will also play a pivotal role in minimizing these defects.
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
Event Management System Vb Net Project Report.pdfKamal Acharya
In present era, the scopes of information technology growing with a very fast .We do not see any are untouched from this industry. The scope of information technology has become wider includes: Business and industry. Household Business, Communication, Education, Entertainment, Science, Medicine, Engineering, Distance Learning, Weather Forecasting. Carrier Searching and so on.
My project named “Event Management System” is software that store and maintained all events coordinated in college. It also helpful to print related reports. My project will help to record the events coordinated by faculties with their Name, Event subject, date & details in an efficient & effective ways.
In my system we have to make a system by which a user can record all events coordinated by a particular faculty. In our proposed system some more featured are added which differs it from the existing system such as security.
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
Forklift Classes Overview by Intella PartsIntella Parts
Discover the different forklift classes and their specific applications. Learn how to choose the right forklift for your needs to ensure safety, efficiency, and compliance in your operations.
For more technical information, visit our website https://intellaparts.com
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSEDuvanRamosGarzon1
AIRCRAFT GENERAL
The Single Aisle is the most advanced family aircraft in service today, with fly-by-wire flight controls.
The A318, A319, A320 and A321 are twin-engine subsonic medium range aircraft.
The family offers a choice of engines
Courier management system project report.pdfKamal Acharya
It is now-a-days very important for the people to send or receive articles like imported furniture, electronic items, gifts, business goods and the like. People depend vastly on different transport systems which mostly use the manual way of receiving and delivering the articles. There is no way to track the articles till they are received and there is no way to let the customer know what happened in transit, once he booked some articles. In such a situation, we need a system which completely computerizes the cargo activities including time to time tracking of the articles sent. This need is fulfilled by Courier Management System software which is online software for the cargo management people that enables them to receive the goods from a source and send them to a required destination and track their status from time to time.
5. Don't test Java
public class MyException extends Exception {
public MyException(String message) {
super(message);
}
}
public void someMethod() throws MyException {
throw new MyException("SomeMessage");
}
@Testpublic void testSomething() {
try {
service.someMethod();
} catch (MyException e) {
assertThat(e.getMessage(), is("SomeMessage"));
}
}
6. Don’t test POJO objects
public class POJO {
private String field;
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
}
@Testpublic void testPojo() {
POJO pojo = new POJO();
pojo.setField("value");
assertThat(pojo.getField(), is("value"));
}
7. I remember growing up with
television, from the time it was
just a test pattern, with maybe a
little bit of programming once in a
while.
— Francis Ford Coppola
8. Mock all external services
and states
@Testpublic void multiple() {
Dao dao = mock(Dao.class);
EmailService emailService = mock(EmailService.class);
RemoteControl remoteControl = mock(RemoteControl.class);
Service service = new Service(dao, emailService, remoteControl);
User user = new User();
doReturn(10).when(emailService).sendEmail();
doReturn(10).when(dao).store(user);
service.save(user);
verify(remoteControl, times(1)).turnOn();
}
9. Avoid unnecessary
preconditions and
verifications
public class Service {
private Dao dao;
public Service(Dao dao) {
this.dao = dao;
}
public int save(User user) {
return dao.store(user);
}
}
public interface Dao {
public int store(Object o);
public Object read() ;
}
@Testpublic void multiple() {
Dao dao = mock(Dao.class);
User user = new User();
Service service = new Service(dao);
doReturn(new User()).when(dao).read();
doReturn(10).when(dao).store(user);
assertThat(service.save(user), is(10));
verify(dao, times(1)).store(user);
}
10. Test one code unit on a time
public class Service {
@Testpublic void multiple() {
Service service = new Service();
assertThat(service.doSomething(), is("something"));
assertThat(service.calculate(), is(10));
}
public String doSomething() {
return "something";
}
public Integer calculate() {
return 10;
}
}
11. Write multiple test scenarios
public class Service {
public String doSomething() { return "something"; }
public Integer calculate() { return 10; }
}
@Testpublic void testDoSomething() {
Service service = new Service();
assertThat(service.doSomething(), is("something"));
}
@Testpublic void testCalculate() {
Service service = new Service();
assertThat(service.calculate(), is(10));
}
12. Don’t rely on indirect testing
public class Service {
public String doSomething() {
return new AnotherService().doSomething();
}
}public class AnotherService {
public String doSomething() {
return "someThing";
}
}
@Testpublic void testAnotherService() {
Service service = new Service();
assertThat(service.doSomething(), is("someThing"));
}
13. Design is not just what it looks like
and feels like. Design is how it
works.
— Steve Jobs
14. If test get complicated, we
need better code design
How to indicate bad code design?
• Complex test objects need to be created to test
simple scenario (otherwise null pointers are fired)
• More than 4 dependencies need to be mocked.
• Test have too much mock statements for one test
scenario
• Test is getting more than ~5-10 lines of code.
• If you get in any of this states,re-factor your code
15. Give tests good names
● shouldCreateNewUserForGivenUsername
● shouldThrowExceptionWhenUsernameIsNull
● shouldStoreUserToDatabase
● shouldActivateUserByUsername
● shouldEncryptUserPassword
● shouldValidateUserPassword
16. Don’t skip unit tests
@Ignore
@Testpublic void testPojo() {
Service service = new Service();
assertThat(service.doSomething(), is("someThing"));
}
● Having invalid test cases in our
source code will not help anyone.
● If test scenario is invalid, then
remove it.
17. Add new tests for every bug
you find
How will this help us?
• Will keep an eye on a bug for us
• Will prevent us of making changes that will make
the bug reappear
• It is the agile way
• It always good to have more unit tests
18. Parametrize where you can
@RunWith(value = Parameterized.class)public class Example {
private final Service service = new Service();
private final String value;
private final boolean result;
@Parameterized.Parameters
public static Collection<Object[]> data() {
final Object[][] data = new Object[][]{ {StringUtils.EMPTY, Boolean.FALSE},
{"123_some", Boolean.FALSE},
{null, Boolean.TRUE}, };
return Arrays.asList(data);
}
public Example(final String value, final boolean result) { this.value = value; this.result =
result; }
@Test
public void isValid() {
assertThat(service.doSomething(value), is(equalTo(result)));
}
}
19. Final notes
Tests are documentation tool. New developer
can have more insight about what code do.
Test everything that could possibly break
Don’t test configuration settings
Don’t test logging
Keep tests independent