Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8809359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:51:22+00:00 2026-06-14T02:51:22+00:00

I have the following method with no modifier declared exactly in my Column class.

  • 0

I have the following method with no modifier declared exactly in my Column class.

float maximumActiveDutyCycle(ArrayList<Column> columns)
{
    // TODO: change public back to default
    float maximumActiveDutyCycle = 0.0f;
    for (Column column : columns)
    {
        if (column.activeDutyCycle > maximumActiveDutyCycle)
        {
            maximumActiveDutyCycle = column.activeDutyCycle;
        }
    }
    return maximumActiveDutyCycle;
}

But I also have the following test method in class TestColumn. I was wondering if someone could tell me how I should test my method since I don’t know how to access it from the Test class. Thanks!

public void testMaximumActiveDutyCycle()
{
    this.column00.setActiveDutyCylce(1.1f);
    this.column01.setActiveDutyCylce(1.3f);
    this.column33.setActiveDutyCylce(1.35f);
    this.column57.setActiveDutyCylce(1.355f);
    Set<Column> columns = new HashSet<Column>();
    columns.add(column00);
    columns.add(column01);
    columns.add(column33);
    columns.add(column57);



}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:51:23+00:00Added an answer on June 14, 2026 at 2:51 am

    Ideally, your unit test class should reside in the same class path package as your class.

    src/main/java/com/yourcompany/project <- your project's classes
    src/test/java/com/yourcompany/project <- your unit tests
    

    So in your unit test class, you could access the method that has package access visibility:

    Column column = new Column()
    column.maximumActiveDutyCycle(columns);
    

    Code example:

    src/main/java/sg/java/test

    package sg.java.test;
    
    public class Myclass {
        float maximumActiveDutyCycle() {
            return 0f;
        }
    }
    

    src/test/java/sg/java/test

    package sg.java.test;
    
    import static org.junit.Assert.assertTrue;
    
    import org.junit.Test;
    
    public class MyclassTest {
        @Test
        public void testMaximumActiveDutyCycle() {
            Myclass clazz = new Myclass();
    
            assertTrue(clazz.maximumActiveDutyCycle() == 0f);
        }
    }
    

    EDIT: Changed the unit test’s class name, should be post fixed with Test instead of prefixed. While the method name should be prefixed with test by convention.

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following method in wcf webenabled service Public Person AddPerson(Person p); As of
I have the following method: public string Phase(string phase) { return Phase 1; }
I have the following method in my UIButton class: - (id)initWithCoder:(NSCoder *)aDecoder{ self =
I have the following method which is called when the value Edit Class... is
I have the following method: public static T ExecuteScalar<T>( string query, SqlConnection connection, params
I have following piece of code: class A { public C GetC() { return
I have the following POJO class for a JSON object: public class JSONChangeSet {
I have the following classes: public class Note { public string Text { get;
I have following method which I am using to load ActiveX control dynamically, Dim
I have the following method, which takes in the name of a file as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.