diff --git a/lectures/revealjs/03-build-tools-and-some-testing.adoc b/lectures/revealjs/03-build-tools-and-some-testing.adoc index 2fc35f1cf5103d496ac3575b8749a51846946984..86997bf07b7ecddec95a22a1e7e6694ad595653a 100644 --- a/lectures/revealjs/03-build-tools-and-some-testing.adoc +++ b/lectures/revealjs/03-build-tools-and-some-testing.adoc @@ -12,12 +12,15 @@ IT1901 Fall 2019 - 3rd Lecture [background-color = "#124990"] [color = "#fff6d5"] == Overview +[.smaller-80] - Feedback from last lecture - Build tools - Gradle - Testing - JUnit - TestFX +- Mockito +- Jacoco [background-color = "#124990"] [color = "#fff6d5"] @@ -233,17 +236,146 @@ Have you succeeded to create the required gradle build? [color = "#fff6d5"] == Testing +== Testing + +[%step] +- is an important part of software development +- a way to ensure software quality +- automated testing allows to develop new features with a minimal effort to check if the software still works as expected +- testing frameworks + +== Testing (2) + +[%step] +- design +- implement +- write automated tests +- run tests +- we do not test just for know, we write tests to keep running them during project life cycle + +== Testing (3) + +[%step] +- design tests +- implement the test +- provide inputs +- run the tests +- provide expected outputs +- check if the result we get matches what we expect +- produce a manageable output that the developer can consult + +== Testing (3) + +- design tests +- implement the test +- provide inputs +- *run the tests* +- provide expected outputs +- *check if the result we get matches what we expect* +- *produce a manageable output that the developer can consult* + [background-color = "#124990"] [color = "#fff6d5"] == JUnit +== JUnit + +- Is a Java unit testing framework. +- provides the means to automate test +- allows to eliminate redundant testing tasks + + +== JUnit (2) + +``` java +import org.junit.*; + +public class FoobarTest { + @BeforeClass + public static void setUpClass() throws Exception { + // Code executed before the first test method + } + + @Before + public void setUp() throws Exception { + // Code executed before each test + } + + @Test + public void testOneThing() { + // Code that tests one thing + } + + @Test + public void testAnotherThing() { + // Code that tests another thing + } + + @Test + public void testSomethingElse() { + // Code that tests something else + } + + @After + public void tearDown() throws Exception { + // Code executed after each test + } + + @AfterClass + public static void tearDownClass() throws Exception { + // Code executed after the last test method + } +} +``` + +[.smaller-40] +https://en.wikipedia.org/wiki/JUnit + + [background-color = "#124990"] [color = "#fff6d5"] == TestFX +== TestFX + +- testing for JavaFx applications +- provides robots for UI testing +- support for JUnit + +[.smaller-40] +https://github.com/TestFX/TestFX + + +[background-color = "#124990"] +[color = "#fff6d5"] +== Mockito + + +== Mockito + +- mocking is a technique to test functionality in isolation +- mock objects simulate real objects +- return dummy values corresponding to the input given at creation +- Mockito uses reflection features in Java to create the mock objects +[.smaller-40] +https://site.mockito.org/ + +[background-color = "#124990"] +[color = "#fff6d5"] +== Jacoco + +== Jacoco + +- tool for assessing code coverage +- does not need modifying code +- can produce a report in html format +- integrates with a number a tools including Gradle + +[.smaller-40] +https://www.jacoco.org/