Skip to main content
deleted 100 characters in body
Source Link
Robert Harvey
  • 200.1k
  • 55
  • 468
  • 679

I have a MVC which has this structure:

  • ui
  • controller
  • db
  • model

Basically the controller doesn't really do much more than connection ui with db layer.

Do I need to provide JUnit tests for the controller (if the program's point matters, it's my semester project)?

Edit: As I have read it now, it sounds I haven't written my homework. What I actually meant was would Would that help me somehow as there isn't much code - I basically take all the parameters and put them, shouldn't this be covered by model layer tests?

Example methods I have in the controller:

Inserting:

public int createEmployeeJob(String jobName)
{
    int result = -3;

    try 
    {       
        EmployeeJob newEmployeeJob = new EmployeeJob();

        newEmployeeJob.setJobName(jobName);

        DBConnection.startTransaction();

        IFEmployeeJob dbEmployeeJob = new DBEmployeeJob();
        result = dbEmployeeJob.createEmployeeJob(newEmployeeJob);

        DBConnection.commitTransaction();
    }
    catch (Exception e)
    {
        DBConnection.rollbackTransaction();
    }

    return result;
}

Retrieving:

public ArrayList<EmployeeJob> printAllEmployeeJobs() throws SQLException
{
    IFEmployeeJob dbEmployeeJob = new DBEmployeeJob();

    return dbEmployeeJob.printAllEmployeeJobs();
}

I have a MVC which has this structure:

  • ui
  • controller
  • db
  • model

Basically the controller doesn't really do much more than connection ui with db layer.

Do I need to provide JUnit tests for the controller (if the program's point matters, it's my semester project)?

Edit: As I have read it now, it sounds I haven't written my homework. What I actually meant was would that help me somehow as there isn't much code - I basically take all the parameters and put them, shouldn't this be covered by model layer tests?

Example methods I have in the controller:

Inserting:

public int createEmployeeJob(String jobName)
{
    int result = -3;

    try 
    {       
        EmployeeJob newEmployeeJob = new EmployeeJob();

        newEmployeeJob.setJobName(jobName);

        DBConnection.startTransaction();

        IFEmployeeJob dbEmployeeJob = new DBEmployeeJob();
        result = dbEmployeeJob.createEmployeeJob(newEmployeeJob);

        DBConnection.commitTransaction();
    }
    catch (Exception e)
    {
        DBConnection.rollbackTransaction();
    }

    return result;
}

Retrieving:

public ArrayList<EmployeeJob> printAllEmployeeJobs() throws SQLException
{
    IFEmployeeJob dbEmployeeJob = new DBEmployeeJob();

    return dbEmployeeJob.printAllEmployeeJobs();
}

I have a MVC which has this structure:

  • ui
  • controller
  • db
  • model

Basically the controller doesn't really do much more than connection ui with db layer.

Do I need to provide JUnit tests for the controller (if the program's point matters, it's my semester project)?

Would that help me somehow as there isn't much code - I basically take all the parameters and put them, shouldn't this be covered by model layer tests?

Example methods I have in the controller:

Inserting:

public int createEmployeeJob(String jobName)
{
    int result = -3;

    try 
    {       
        EmployeeJob newEmployeeJob = new EmployeeJob();

        newEmployeeJob.setJobName(jobName);

        DBConnection.startTransaction();

        IFEmployeeJob dbEmployeeJob = new DBEmployeeJob();
        result = dbEmployeeJob.createEmployeeJob(newEmployeeJob);

        DBConnection.commitTransaction();
    }
    catch (Exception e)
    {
        DBConnection.rollbackTransaction();
    }

    return result;
}

Retrieving:

public ArrayList<EmployeeJob> printAllEmployeeJobs() throws SQLException
{
    IFEmployeeJob dbEmployeeJob = new DBEmployeeJob();

    return dbEmployeeJob.printAllEmployeeJobs();
}
added a better description
Source Link
Nikola
  • 367
  • 1
  • 9

I have a MVC which has this structure:

  • ui
  • controller
  • db
  • model

Basically the controller doesn't really do much more than connection ui with db layer.

Do I need to provide JUnit tests for the controller (if the program's point matters, it's my semester project)?

Edit: As I have read it now, it sounds I haven't written my homework. What I actually meant was would that help me somehow as there isn't much code - I basically take all the parameters and put them, shouldn't this be covered by model layer tests?

Example methods I have in the controller:

Inserting:

public int createEmployeeJob(String jobName)
{
    int result = -3;

    try 
    {       
        EmployeeJob newEmployeeJob = new EmployeeJob();

        newEmployeeJob.setJobName(jobName);

        DBConnection.startTransaction();

        IFEmployeeJob dbEmployeeJob = new DBEmployeeJob();
        result = dbEmployeeJob.createEmployeeJob(newEmployeeJob);

        DBConnection.commitTransaction();
    }
    catch (Exception e)
    {
        DBConnection.rollbackTransaction();
    }

    return result;
}

Retrieving:

public ArrayList<EmployeeJob> printAllEmployeeJobs() throws SQLException
{
    IFEmployeeJob dbEmployeeJob = new DBEmployeeJob();

    return dbEmployeeJob.printAllEmployeeJobs();
}

I have a MVC which has this structure:

  • ui
  • controller
  • db
  • model

Basically the controller doesn't really do much more than connection ui with db layer.

Do I need to provide JUnit tests for the controller (if the program's point matters, it's my semester project)?

Example methods I have in the controller:

Inserting:

public int createEmployeeJob(String jobName)
{
    int result = -3;

    try 
    {       
        EmployeeJob newEmployeeJob = new EmployeeJob();

        newEmployeeJob.setJobName(jobName);

        DBConnection.startTransaction();

        IFEmployeeJob dbEmployeeJob = new DBEmployeeJob();
        result = dbEmployeeJob.createEmployeeJob(newEmployeeJob);

        DBConnection.commitTransaction();
    }
    catch (Exception e)
    {
        DBConnection.rollbackTransaction();
    }

    return result;
}

Retrieving:

public ArrayList<EmployeeJob> printAllEmployeeJobs() throws SQLException
{
    IFEmployeeJob dbEmployeeJob = new DBEmployeeJob();

    return dbEmployeeJob.printAllEmployeeJobs();
}

I have a MVC which has this structure:

  • ui
  • controller
  • db
  • model

Basically the controller doesn't really do much more than connection ui with db layer.

Do I need to provide JUnit tests for the controller (if the program's point matters, it's my semester project)?

Edit: As I have read it now, it sounds I haven't written my homework. What I actually meant was would that help me somehow as there isn't much code - I basically take all the parameters and put them, shouldn't this be covered by model layer tests?

Example methods I have in the controller:

Inserting:

public int createEmployeeJob(String jobName)
{
    int result = -3;

    try 
    {       
        EmployeeJob newEmployeeJob = new EmployeeJob();

        newEmployeeJob.setJobName(jobName);

        DBConnection.startTransaction();

        IFEmployeeJob dbEmployeeJob = new DBEmployeeJob();
        result = dbEmployeeJob.createEmployeeJob(newEmployeeJob);

        DBConnection.commitTransaction();
    }
    catch (Exception e)
    {
        DBConnection.rollbackTransaction();
    }

    return result;
}

Retrieving:

public ArrayList<EmployeeJob> printAllEmployeeJobs() throws SQLException
{
    IFEmployeeJob dbEmployeeJob = new DBEmployeeJob();

    return dbEmployeeJob.printAllEmployeeJobs();
}
Source Link
Nikola
  • 367
  • 1
  • 9

Do I need JUnit tests for the controller layer on a MVC when I have a database layer

I have a MVC which has this structure:

  • ui
  • controller
  • db
  • model

Basically the controller doesn't really do much more than connection ui with db layer.

Do I need to provide JUnit tests for the controller (if the program's point matters, it's my semester project)?

Example methods I have in the controller:

Inserting:

public int createEmployeeJob(String jobName)
{
    int result = -3;

    try 
    {       
        EmployeeJob newEmployeeJob = new EmployeeJob();

        newEmployeeJob.setJobName(jobName);

        DBConnection.startTransaction();

        IFEmployeeJob dbEmployeeJob = new DBEmployeeJob();
        result = dbEmployeeJob.createEmployeeJob(newEmployeeJob);

        DBConnection.commitTransaction();
    }
    catch (Exception e)
    {
        DBConnection.rollbackTransaction();
    }

    return result;
}

Retrieving:

public ArrayList<EmployeeJob> printAllEmployeeJobs() throws SQLException
{
    IFEmployeeJob dbEmployeeJob = new DBEmployeeJob();

    return dbEmployeeJob.printAllEmployeeJobs();
}