Git Product home page Git Product logo

st-5-new's Introduction

ST-5 Модульное тестирование на Java с использованием jUnit и Maven

GitHub pull requests GitHub closed pull requests

Срок выполнения задания:

по 05.05.24 Relative date

Задание №1

В среде Intellij Idea создать проект Maven по шаблону quickstart. Убедиться в появлении веток java/main и java/test в разделе src проекта, а также файла с конфигурацией pom.xml в корне проекта.

Добавить в проект класс Sqrt, содержащий алгоритм вычисления квадратного корня методом последовательных приближений.

class Sqrt
{
   double delta=0.00000001;
   double arg;

   public Sqrt(double arg) {
      this.arg=arg;
   }
   public double average(double x,double y) {
      return (x+y)/2.0;
   }
   public boolean good(double guess,double x) {
      return Math.abs(guess*guess-x)<delta;
   }
   public double improve(double guess,double x) {
      return average(guess,x/guess);
   }
   public double iter(double guess, double x) {
      if(good(guess,x))
         return guess;
      else
         return iter(improve(guess,x),x);
   }
   public double calc() {
      return iter(1.0,arg);
   }
}

В класс Program можно поместить следующий демонстрационный пример:

class Program
{
   public static void main(String[] args)
   {
      double val=Double.parseDouble("2.0");
      Sqrt sqrt=new Sqrt(val);
      double result=sqrt.calc();
      System.out.println("Sqrt of " + val + " = " + result);
   }
}

Далее, построить проект и убедиться, что консольное приложение запускается без ошибок и выводит на экран некоторую информацию.

Задание №2

Добавить в проект поддержку jUnit и поместить в соответствующий исходный файл тесты для покрытия всех методов класса Sqrt. провести анализ покрытия средствами Intellij Idea.

Задание №3

Загрузить проект на GitHub и убедиться в работоспособности проектами через сценарии GH Actions.

st-5-new's People

Contributors

ashtanyuk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.