Questions tagged [private-methods]
285 questions
4
votes
2 answers
Category accessing private methods of main class - Objective C
Due to the circumstances of what I'm programming, I need to implement some methods in a class without actually editing the class, so I am using categories.
The trouble is there are methods not included in the interface of the class, but are…

alex_joker
- 73
- 5
4
votes
0 answers
Ruby private attr_writer and += causes NoMethodError
I'm a bit stumped. Take a look at the add_one method below. When using the increment += operator Ruby throws a NoMethodError. The verbose version works fine.
private method `count=' called for #…

Mohamad
- 34,731
- 32
- 140
- 219
4
votes
2 answers
How to match 'any' parameter type while mocking private method in Jmockit
I have a problem while using jmockit for the following scenario. Did a research on the web, but couldn't locate the answers yet.
In the record phase, I am setting the expectation on an object that is partially mocked. While doing it, I would like…

Alex Vincent
- 41
- 1
- 1
- 5
4
votes
4 answers
Getting “private method” in a “public function” class using CoffeeScript
I'm doing a series of tests with classes and CoffeeScript/JavaScript. See the following code:
class Example
someFunction = ->
alert @getText()
constructor: ->
@text = 'Hello world! ;)'
someFunction()
getText:…

Caio Tarifa
- 5,973
- 11
- 46
- 73
4
votes
1 answer
Private method error using object.entities in Twitter API
I am getting the following error when trying to call tweet.entities in my twitter feed controller.
private method `entities' called for #Twitter::Status:0x94d4bf4
I have no methods called entities in the code, I even did a full file search to…

chestermano
- 853
- 6
- 12
3
votes
4 answers
Allow class access to single private member
I have a class A which has a private method called a(). I have also a class B which needs to access a() (but just B should have access to a(), thats why a() is private). I could now use a friend specifier but that would make other private methods of…

Sebastian Hoffmann
- 11,127
- 7
- 49
- 77
3
votes
0 answers
How do I test private class methods with Jest?
I have a class with private methods:
class MyClass {
#myMethod () {}
}
Is it possible to test it with Jest?

user5507535
- 1,580
- 1
- 18
- 39
3
votes
6 answers
Is it allowed for a class to implement an interface plus additional private method(s) in C#?
I have the following interface:
interface IExcelServices
{
Dictionary FilterFields(Dictionary excelContent);
Dictionary ParseExcelFile(string path);
}
Which is implemented by the…

CiccioMiami
- 8,028
- 32
- 90
- 151
3
votes
1 answer
How to get private methods working in TypeScript?
I have some code that looks roughly like:
class A {
#hidden = 0;
method() {
return this.#hidden;
}
}
This works fine when I use JS, but when I convert it to TS I get the error Parsing error: Invalid character because of the #. Is there…

Dan Mandel
- 637
- 1
- 8
- 26
3
votes
2 answers
Unit test private methods by making them free functions
In the 2017 cppcon videos, I came across a talk by Klaus Iglberger which was entitled "Free Your Functions!".
In this talk, the speaker talked about how switching to free functions could
easy up the process of testing private methods (See at…

BobMorane
- 3,870
- 3
- 20
- 42
3
votes
1 answer
Private methods in service layer
I have a situation:
I want to provide a service class with one functionality, for example:
generating json file based on some params.. So I have one public method, and some private methods invoked by the public one. There are some private methods,…

Kamil Gołąbek
- 65
- 1
- 10
3
votes
3 answers
Testing Unexported Functions in Go
I have a file called example.go and another test file called example_test.go and they are both in the same package. I would like to test some unexported functions in example.go
When I run the test, the unexported functions are undefined in…

gogofan
- 533
- 1
- 10
- 20
3
votes
2 answers
Testing classes with threads, events, and private methods
general consensus
I've done quite a lot of reading up on the subject of testing complex classes and private methods.
The general consensus seems to be:
"if you need to test private methods then you're class is badly designed"
"if your class is…

andy
- 8,775
- 13
- 77
- 122
3
votes
2 answers
iOS10: App rejected due to method called "removeEvents"
Is there any list of methods which are not allowed when they are compiled in the application? Or a syntax that is not allowed?
With this message from Connect recently our app has been rejected due to the removeEvents method name:
Your app uses or…

Vladimír Slavík
- 1,727
- 1
- 21
- 31
3
votes
1 answer
Why cannot a const qualified method be called on a non const object if a non const qualified private method exists?
The following code does not compile:
struct A {
void f () const { }
private:
void f () { }
};
int main () {
A a_nc;
const A a_c;
a_nc.f();
a_c.f();
return 0;
}
The error:
test.cpp: In function 'int…

Holt
- 36,600
- 7
- 92
- 139