4 § What? The practice of automating the integration of code changes from multiple contributors into a single software project. Continuous Integration (CI) https://www.pagerduty.com
31 2. Code • Add this class: public class Main { public static void main(String args[]) { hypothenuse(10, 20); } public static double hypothenuse(double a, double b) { return Math.sqrt(Math.pow(a,2) + Math.pow(b,2)); } } • It should be in src/main/java folder. • Check your Maven
32 3. Test Case • Create a test case. You can do that by selecting your class name, right-clicking, selecting generate…/Test… • Select the method to be tested and click OK.
33 4. Junit Dependency • Either your IDE takes car of the dependency or goes and add it manually as follows (this is Junit 5) <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>5.8.2</version> <scope>test</scope> </dependency> </dependencies>
34 5. Run Your Test Case • You can test something like this: import org.junit.jupiter.api.Assertions; class MainTest { @Test void hypothenuse() { Assertions.assertEquals( Main.hypothenuse(10,20), 22.360679774997898 ); } }
35 6. Build • And let us ask Maven to build the application also. <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.2</version> </plugin> </plugins> </build>
38 9. GitHub readme.md 1. Go To GitHub and add a README.md file 2. Edit the README file and add your names (only team members present) 3. Add me as a collaborator (javiergs)
40 11. GitHub Actions Permissions 1. If the Build fails, then go to Settings/Actions/General and provide Read and Write permissions to Workflow 2. Review your Java versions 8. 11, 15, 19 etc. It is better if they match.
44 12. GitHub Actions <<Optional>> 1. Deploy a JAR file as an Artifact inside of Workflow results 2. Look to your POM.xml for this <groupId>javiergs</groupId> <artifactId>testing-2024</artifactId> <version>1.0-SNAPSHOT</version>
45 12. GitHub Actions <<Optional>> 1. Deploy a JAR file as an Artifact inside of Workflow results 2. Look to your POM.xml for this <groupId>javiergs</groupId> <artifactId>testing-2024</artifactId> <version>1.0-SNAPSHOT</version>
Winter 2023 Copyright. These slides can only be used as study material for the class CSC308 at Cal Poly. They cannot be distributed or used for another purpose.